c# - Clicking on Html.ActionLink refreshing the layout view -
i have mvc 3 project created default template in visual studio. in project in layout view added dropdownlist using view , html.action like
in _layout.cshtml
@html.action("index", "ddldept")
in index.cshtml of ddldeptcontroller.cs
@model passingvaluesinviews.models.ddldeptviewmodel @html.dropdownlistfor(m => m.selecteddeptid, new selectlist(model.depts, "id" , "deptname"))
when run project , click on 1 of default links home controller
<li>@html.actionlink("home", "index", "home")</li>
the page refreshed , whatever selected in dropdownbox cleared , default valued selected again.
why dropdownbox refesh , how prevent that.
my objective have common dropdown box couple of views.
thanks help.
@html.actionlink refresh page. same action occur if clicked on link generated traditional tags.
if needed reload small section, you're looking ajax call via @ajax.actionlink.
@ajax.actionlink("home", // <-- text display "index", // <-- action method name new ajaxoptions { updatetargetid="customerlist", // <-- dom element id update insertionmode = insertionmode.replace, // <-- replace content of dom element httpmethod = "get" // <-- http method })
sample taken following tutorial: http://www.c-sharpcorner.com/uploadfile/abhikumarvatsa/ajax-actionlink-and-html-actionlink-in-mvc/
Comments
Post a Comment