Arkadiusz Raszeja Arkadiusz Raszeja - 2 months ago 9
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
as empty string. Any guesses what can be wrong?


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