Retrieveing values form server side textboxes

Discussion in 'ASP .Net Web Controls' started by Kerri, Oct 27, 2003.

  1. Kerri

    Kerri Guest

    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.
    Kerri, Oct 27, 2003
    #1
    1. Advertising

  2. Kerri

    Guest 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

    >-----Original Message-----
    >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.
    >.
    >
    Guest, Oct 28, 2003
    #2
    1. Advertising

  3. Kerri

    Joel Finkel Guest

    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






    "Kerri" <> wrote in message news:030b01c39cc4$513162e0$...
    > 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.
    Joel Finkel, Nov 8, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Henry

    retrieveing entire user agent

    Brian Henry, Dec 22, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    386
    Brian Henry
    Dec 22, 2003
  2. Mythran
    Replies:
    2
    Views:
    499
    Mythran
    Jan 22, 2005
  3. Thor
    Replies:
    1
    Views:
    1,002
    Mikkel Heisterberg
    Jul 2, 2003
  4. EmJayEm
    Replies:
    0
    Views:
    104
    EmJayEm
    Jan 15, 2005
  5. Renuka
    Replies:
    1
    Views:
    112
    Michael Winter
    Nov 13, 2003
Loading...

Share This Page