HOW TO USE TEXTBOX AND VIEWBAG VALUE IN CONTROLLER METHOD?

Mark M

Total Post:28

Points:196
Posted by  Mark M
 965  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. Kamlakar Singh

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!