Saturday, March 31, 2012

Server Side Controls in ASP.NET

Hi,

I have an aspx page with some server side textboxes.

I have a button onmy page which allows users to add data
to a database.

In my onclick event for my button when I try and get teh
value from the textbox using..

Dim myString as String = textbox1.text

...it is blank.

When I do a..

Dim myString = Request.Form("textbox1")

...I get the value the user enetered.

I have declared my textbox as a control in my codebehind.

And it is an asp.net textbox.

Any ideas why this is?

This is baffling me.

Kerri.Have you added the "runat=server" attribute to the template HTML for the
text box?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Kerri" <anonymous@.discussions.microsoft.com> wrote in message
news:017401c39cc4$12c55070$a501280a@.phx.gbl...
> Hi,
> I have an aspx page with some server side textboxes.
> I have a button onmy page which allows users to add data
> to a database.
> In my onclick event for my button when I try and get teh
> value from the textbox using..
> Dim myString as String = textbox1.text
> ..it is blank.
> When I do a..
> Dim myString = Request.Form("textbox1")
> ..I get the value the user enetered.
> I have declared my textbox as a control in my codebehind.
> And it is an asp.net textbox.
> Any ideas why this is?
> This is baffling me.
> Kerri.

No comments:

Post a Comment