How to use textbox and ViewBag value in controller method?

Total Post:28

Points:196
 1351  View(s)
Ratings:
Rate this:
@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;
}

  1. Post:194

    Points:1396
    Re: How to use textbox and ViewBag value in controller method?

    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.

      Modified On Apr-07-2018 12:58:39 AM

Answer