如何在方法参数中获取两个文本框值?

时间:2014-03-11 05:24:47

标签: razor

<body >
<a href="#" class="close"></a>

@using (Html.BeginForm("sendcode", "Home", FormMethod.Post))
{
<div id="popup">
<div class="selected">You Selected:</div>
<div class="sname">@ViewBag.selectsong</div>
<input name="sSongName" type="hidden" value="@ViewBag.selectsong"/>
<div class="enter" style="width:458px;height:37px; text-align:left;">
<div class="selected">Enter your mobile number</div>

<div class="mobileno">
<div><div class="spann">+91</div><input name="MNumber" type="text" class="mobileinput"/></div>
</div>
<div class="confirm">
<input name="" type="button" class="confirmb" value="Confirm" onclick="@Url.Action("sendcode", "Home", new { })"/>
</div>
<div class="applicablee">* charges applicable</div>
</div>

</div>
}
</body>

下面是我在Home控制器中编写的方法,我想在方法中检索textvalue作为参数?

 public string sendcode(string MNumber, string SongName)
        {
return (MNumber+" "+SongName);
}

1 个答案:

答案 0 :(得分:0)

您需要将参数名称与输入字段的name属性相匹配。

<input name="sSongName" type="hidden" value="@ViewBag.selectsong"/>
<input name="MNumber" type="text" class="mobileinput"/>


public string sendcode(string sSongName, string MNumber)
{
     //Do Something
}