0

In view page, I have an html.actionlink: 1. How to call from html.actionlink, an actionresult name, that is inside the homecontroller(How to write the address of the controller and function, in actionlink?) 2. How to pass a number of variables from view\html.actionlink to homecontroller\actionresult? Thanks

1
  • You can pass the varibales like id as part of the routeValues parameter of the RedirectToAction() method. return RedirectToAction("Action", "Controller", new { id = 12 }); This will cause a redirect to Site/Controller/Action/12. Commented Oct 26, 2018 at 11:57

2 Answers 2

1
Html.ActionLink(article.Title, "ActionName", "ControllerName", new { id = article.ArticleID, title = article.Title }, null)
Sign up to request clarification or add additional context in comments.

Comments

0

I suggest you for passing some variables from View to controller/action to use this simple way :

submit button

So now whene you clicked in the button the form will be submit and will be pass the text value that have IH="test_var" to the action . Now in the controller we use this method to get the variable :

Imagin we have a controller that named controller inside this controller we use

Public actionresult simple_action (string test_var) {

//here you can write what you want to code

}

I wish this help you brother .

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.