How to use textbox and ViewBag value in controller method?

@using (Html.BeginForm("sendcode","Home", FormMethod.Post))
{
<div class="selected">You Selected:</div>
<div class="sname">@ViewBag.selectsong</div>
<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>`enter code here`
<div class="confirm"><input name="" type="button" class="confirmb"value="Confirm"onclick="location.href='@Url.Action("getdetail", "Home" )'/>
</div>
<div class="applicablee">* charges applicable as per your mobile operators</div>
</div>
}

I want to use textbox value and ViewBag value on my controller method which has been defined below?

 

public string getdetail(string Mnumber, string sSongName)
{
    string ss =Mnumber;
    string ss1 =sSongName;
    return ss;
}

Last updated:11/27/2014 12:28:08 AM

1 Answers

Anonymous User
Anonymous User

If you want to fill your textbox with ViewBag value try this;

<input type='textbox' id='aa' name='aa' value='@Viewbag.X'/>

If you want to pass that value use hidden method Satpal mentioned about.

Answer