从View中获取值到控制器 [英] Fetching values from View to controller

查看:105
本文介绍了从View中获取值到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在练习mvc。从示例应用开始。代码如下

设计页面

Hi to all,
i am practing mvc. started with sample application. the code is as follows
Design page

    <form action="Save">
    <div>
        <aside>
        @Html.ActionLink("Home", "Index", "Home")
        </aside>
        @Html.Label("Cluster Id")
        @Html.TextBox("txtid")
        @Html.Label("Cluster Desc")
        @Html.TextBox("txtdesc")
        <input type="submit" id="btns" value="Save Test" />
    </div>
    </form>
</body





控制器



Controller

Function Save(ByVal val As FormCollection) As ActionResult
  If val("txtid") = 1 AndAlso val("txtdesc") = "ED" Then
       ViewBag("ret") = "received values"
  Else
       ViewBag("ret") = "not received"
  End If
  Return View(ViewBag)
End Function




上面的代码控制器中的
被调用但在文本框中输入的值没有得到

请在此代码中提示错误



在此先感谢



in the above code controller was invoked but values entered in textboxes are not getting
please suggest what wrong in this code

Thanks in advance

推荐答案

试试这个链接

http://stack247.wordpress.com/2011/03/20/get-forms-post-values-in- asp-net-mvc-with-formcollection / [ ^ ]



希望这有助于
Try this link
http://stack247.wordpress.com/2011/03/20/get-forms-post-values-in-asp-net-mvc-with-formcollection/[^]

Hope this helps


这篇关于从View中获取值到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆