Reputation: 24699
I have this in my ASPX page:
<input id="MY_LAST_FOCUS" name="MY_LAST_FOCUS" type="text" runat="server" />
In the Form Load of my VB.NET code behind I have this:
Dim s as String = Request("MY_LAST_FOCUS")
Why is s always empty even though the MY_LAST_FOCUS HTML text box has text in it?
Upvotes: 2
Views: 1547
Reputation: 512
Its empty because you seem to be grabbing from the Request object for something named what your input is, and not grabbing the contents of your input itself.
Upvotes: 0
Reputation: 9664
I agree with Jack, but if you want to keep it a plain old HTML input box, you could just get the value of it:
Dim s As String = MY_LAST_FOCUS.Value
This only works as long as you keep runat="server"
on it though. And like Jack points out, you probably should just use an ASP.NET TextBox
control instead.
Upvotes: 0
Reputation: 38533
Dim s as String = Request.Form(MY_LAST_FOCUS)
This works for me.
I agree with @Jack Marchetti though.
Upvotes: 2
Reputation: 21905
If you want to access directly from the request, then use the UniqueID of the control:
Request.Form[MY_LAST_FOCUS.UniqueID]
Upvotes: 1
Reputation: 15754
Why don't you use:
<asp:Textbox ID="MY_LAST_FOCUS" runat="server">
then in your code_behind you can access:
Dim s as String = MY_LAST_FOCUS.Text
Upvotes: 5