0

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?

3
  • 1
    Check in the network tab in your browser that the input's value actually sent. Commented Oct 26, 2016 at 11:00
  • It used to save value in database. When I hardcode some value, like baner.Url_link = "google.com"; it works crrectly. Commented Oct 26, 2016 at 11:07
  • 1
    Sure. What I mean is that you can check if the input's value sent correctly to the server using network tab. Commented Oct 26, 2016 at 12:15

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

3 Comments

Certainly, if you want to post it with your form to a server, when submitting the whole form, then you should put it between form tags. Or do you strive to send it by ajax?
I used Html.BeginForm and it works.<br> However now I have different issue, after using 'new { enctype = "multipart/form-data" }' I can't pass other parameters. Anyway thank you :)
Do you mean passing additional parameters to the server? You can always use the method version with the routeValues parameter for this purpose. Actually, you don't even have to use 'enctype = "multipart/form-data"' if you don't need to pass binary data from your form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.