Retrieveing values form server side textboxes

K

Kerri

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.
 
G

Guest

Hi Kerry,
I have declared my textbox as a control in my codebehind.
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
 
J

Joel Finkel

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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top