Arkadiusz Raszeja Arkadiusz Raszeja - 1 month ago 7
HTML Question

getting value of input text from html to mvc

I have textbox containing the url. In html it looks like this:

<input id="BannerLink1" name="BannerLink1" type="text" value="@ViewBag.baner1_link" />


I'm trying to get this value to controller using Request object:

baner.Url_link = Request["BannerLink1"];


But my controller always see
Request["BannerLink1"]
as empty string. Any guesses what can be wrong?

Answer

You need to put your input-tag inside form tags (Html.BeginForm()) to put the value when the form posts.