ASP.NET provides an ActionResult parameter

I am new to asp.net, I really want to give an ActionResult parameter.

I want this to be so (I don't know if this is possible)

Sudoku s = new Sudoku();
//  SudokuClass has a property -> public int[,] MyFields {get;set;}

 public ActionResult Index(int value) 
 {    
    if(value == 1)
    {
        myGame.Create();
        s.MyFields = myGame.GameField();
    }

    if(value == 2)
    {
        myGame.Cheat();
        s.MyFields = myGame.GameField(); 
    }

    if(value == 3)
    // some code

    return View(s);
}

MyCode - Index.cshtml

@Html.ActionLink("Cheat", "Index")

I want: if I click on the actionlink "Cheat", I can give number 2 to start the Cheat Method and update s.MyFields;

Another code to display the fields that I skipped. I can show the fields on the webpage when I use s.MyFields = mygame.GetFields (). So this is not a problem, the problem is how I can “update” it when I click on cheat.

+4
source share
1 answer
@Html.ActionLink("Cheat", "Index", new { value = 2}) 

Or any number you want to transfer from your submission.

+2

Source: https://habr.com/ru/post/1622818/


All Articles