Home > DeveloperSection > Forums > How to use textbox and ViewBag value in controller method?
Kamlakar Singh
Kamlakar Singh

Total Post:28

Posted on    November-26-2014 10:04 PM

 ASP.Net C#  Controller  Viewbag 

 1 Reply(s)
 903  View(s)
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 class="applicablee">* charges applicable as per your mobile operators</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;


Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    November-27-2014 12:28 AM

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.

Don't want to miss updates? Please click the below button!

Follow MindStick