开发者

How to get value from View to Controller

开发者 https://www.devze.com 2023-01-26 05:13 出处:网络
Sorry, My English is not good, 开发者_运维问答I have a View: <div class=\"editor-field\" id = \"nick\">Nick <%: Html.TextBoxFor(model => model.Nick)%><img src=\"/Content/Images/loa

Sorry, My English is not good,

开发者_运维问答I have a View:

<div class="editor-field" id = "nick">Nick <%: Html.TextBoxFor(model => model.Nick)%><img src="/Content/Images/loading.gif" alt = "loading...."/>
        <%: Ajax.ActionLink("Check", "Check", new AjaxOptions { UpdateTargetId = "check-valid", LoadingElementId = "loading"})%>
        </div>

I used: Nick = ViewData.Model.Nick in ActionLink as below, but I cannot get value of Nick from View. Please help me

<%: Ajax.ActionLink("Check", "Check", new {Nick = ViewData.Model.Nick}, new AjaxOptions { UpdateTargetId = "check-valid", LoadingElementId = "loading"})%>


<% using (Html.BeginFormBegin()){%>

<div class="editor-field" id = "nick">Nick <%: Html.TextBoxFor(model => model.Nick)%><img src="/Content/Images/loading.gif" alt = "loading...."/>
        <%: Ajax.ActionLink("Check", "Check", new AjaxOptions { UpdateTargetId = "check-valid", LoadingElementId = "loading"})%>
        </div>

<input type="submit" value="Submit" />

<%}%>

In your controller your corresponding action should be something like:

[HttpPost]
public ActionResult MyForm(string nick)
{
    //nick - should contain the value from the form

    return View();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消