Groups | Blog | Home
all groups > asp.net webcontrols > october 2003 >

asp.net webcontrols : Retrieveing values form server side textboxes


Kerri
10/27/2003 11:55:48 AM
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.

anonymous NO[at]SPAM discussions.microsoft.com
10/27/2003 7:42:04 PM
Hi Kerry,

[quoted text, click to view]
I think the box shgould be declared as a TextBox as a
Control does not have a Text property.

In all of my code-behind modules, here is what my
declarations look like :

Protected WithEvents textbox1 As
System.Web.UI.WebControls.TextBox

This is how the designed would create the refernce if you
were to drag a text box control from the toolbox.

Also, is your textbox contained within another server-
side control ? Perhaps a panel ? It is the case, you must
use oParentControl.FindControl("textbox1").

Another safe way to reference your text box is :

Dim txt as TextBox

txt = Page.FindControl("testbox1") and check if txt is
nothing.

Hope this helps,

Ben

[quoted text, click to view]
Joel Finkel
11/8/2003 4:33:11 PM
Kerri,

Have you set the TextMode of your TextBox to MultiLine? I have run into =
a similar problem using a TextBox that is set this way. The text =
entered by the user does not seem to be returned. Text that is =
pre-loaded is displayed and returned, but no modifications to it by the =
user are returned.

I have only seen this behavior with MultiLine TextBoxes.

Regards,
Joel Finkel
finkel@sd-il.com





[quoted text, click to view]
AddThis Social Bookmark Button