Get text in TextBox without pressing Enter key

Discussion in 'ASP .Net' started by mg, Jul 14, 2003.

  1. mg

    mg Guest

    I want to enter characters in a TextBox in a WebForm,
    press a Button in the WebForm, and read the characters
    that were typed into the TextBox from within the
    Button_Click event handler. The main point here is that I
    want to read the value typed into the TextBox without
    hitting the Enter key or setting focus on another
    control ...
     
    mg, Jul 14, 2003
    #1
    1. Advertising

  2. mg

    mg Guest

    P.S. I need a C# solution. Thanks.


    >-----Original Message-----
    >I want to enter characters in a TextBox in a WebForm,
    >press a Button in the WebForm, and read the characters
    >that were typed into the TextBox from within the
    >Button_Click event handler. The main point here is that I
    >want to read the value typed into the TextBox without
    >hitting the Enter key or setting focus on another
    >control ...
    >
    >
    >
    >.
    >
     
    mg, Jul 14, 2003
    #2
    1. Advertising

  3. mg

    dj Bass Guest

    double clicking on the button in the design view that you want to use will
    provide you with the event handler you require, alternatively you can just
    create a empty method which would look something like this:

    Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles btnSubmit.Click

    end sub.


    then, say your edit box has the id = "editBoxText". You'll be able to call
    the editBoxText.Text() method on that member variable created for that
    control and access the text.

    is that what you wanted or did i miss the boat?

    if you want to set the focus from the submit button back to the edit box,
    check out this website for a short method on setting focus...

    http://aspnetweblog.com/posts/7115.aspx


    "mg" <> wrote in message
    news:03e301c34a02$c5c555e0$...
    > I want to enter characters in a TextBox in a WebForm,
    > press a Button in the WebForm, and read the characters
    > that were typed into the TextBox from within the
    > Button_Click event handler. The main point here is that I
    > want to read the value typed into the TextBox without
    > hitting the Enter key or setting focus on another
    > control ...
     
    dj Bass, Jul 14, 2003
    #3
  4. mg,

    Then the code that dj Bass just gave you is what you want.

    You get the text with:

    MyTextBox.Text

    Justin


    "mg" <> wrote in message
    news:08b301c34a0a$a0993770$...
    > I have an event handler for the button click event. What I
    > need is [C#] code to place in this event handler. The code
    > needs to read the characters in the TextBox without my
    > having [physically] pressed the enter key after entering
    > the characters in the TextBox or having given another
    > control focus by pressing on it with the mouse.
    >
    >
    > >-----Original Message-----
    > >double clicking on the button in the design view that you

    > want to use will
    > >provide you with the event handler you require,

    > alternatively you can just
    > >create a empty method which would look something like

    > this:
    > >
    > >Private Sub btnSubmit_Click(ByVal sender As

    > System.Object, ByVal e As
    > >System.EventArgs) Handles btnSubmit.Click
    > >
    > >end sub.
    > >
    > >
    > >then, say your edit box has the id = "editBoxText".

    > You'll be able to call
    > >the editBoxText.Text() method on that member variable

    > created for that
    > >control and access the text.
    > >
    > >is that what you wanted or did i miss the boat?
    > >
    > >if you want to set the focus from the submit button back

    > to the edit box,
    > >check out this website for a short method on setting

    > focus...
    > >
    > >http://aspnetweblog.com/posts/7115.aspx
    > >
    > >
    > >"mg" <> wrote in message
    > >news:03e301c34a02$c5c555e0$...
    > >> I want to enter characters in a TextBox in a WebForm,
    > >> press a Button in the WebForm, and read the characters
    > >> that were typed into the TextBox from within the
    > >> Button_Click event handler. The main point here is that

    > I
    > >> want to read the value typed into the TextBox without
    > >> hitting the Enter key or setting focus on another
    > >> control ...

    > >
    > >
    > >.
    > >
     
    S. Justin Gengo, Jul 14, 2003
    #4
  5. mg

    dj Bass Guest

    Unless you expect the event handler for a button to simply pick up the text
    from the text box as you write? which wouldn't work, you'd need an event
    handler for the text box on the text change event...

    as they say in Zulu, angaas.

    "S. Justin Gengo" <> wrote in message
    news:...
    > mg,
    >
    > Then the code that dj Bass just gave you is what you want.
    >
    > You get the text with:
    >
    > MyTextBox.Text
    >
    > Justin
    >
    >
    > "mg" <> wrote in message
    > news:08b301c34a0a$a0993770$...
    > > I have an event handler for the button click event. What I
    > > need is [C#] code to place in this event handler. The code
    > > needs to read the characters in the TextBox without my
    > > having [physically] pressed the enter key after entering
    > > the characters in the TextBox or having given another
    > > control focus by pressing on it with the mouse.
    > >
    > >
    > > >-----Original Message-----
    > > >double clicking on the button in the design view that you

    > > want to use will
    > > >provide you with the event handler you require,

    > > alternatively you can just
    > > >create a empty method which would look something like

    > > this:
    > > >
    > > >Private Sub btnSubmit_Click(ByVal sender As

    > > System.Object, ByVal e As
    > > >System.EventArgs) Handles btnSubmit.Click
    > > >
    > > >end sub.
    > > >
    > > >
    > > >then, say your edit box has the id = "editBoxText".

    > > You'll be able to call
    > > >the editBoxText.Text() method on that member variable

    > > created for that
    > > >control and access the text.
    > > >
    > > >is that what you wanted or did i miss the boat?
    > > >
    > > >if you want to set the focus from the submit button back

    > > to the edit box,
    > > >check out this website for a short method on setting

    > > focus...
    > > >
    > > >http://aspnetweblog.com/posts/7115.aspx
    > > >
    > > >
    > > >"mg" <> wrote in message
    > > >news:03e301c34a02$c5c555e0$...
    > > >> I want to enter characters in a TextBox in a WebForm,
    > > >> press a Button in the WebForm, and read the characters
    > > >> that were typed into the TextBox from within the
    > > >> Button_Click event handler. The main point here is that

    > > I
    > > >> want to read the value typed into the TextBox without
    > > >> hitting the Enter key or setting focus on another
    > > >> control ...
    > > >
    > > >
    > > >.
    > > >

    >
    >
     
    dj Bass, Jul 14, 2003
    #5
  6. mg

    Vikram.NET Guest

    Hi,

    It is not clear what you actually want to do.

    You have said that after entering text in the textbox, you
    will be pressing a Button in the web form. When you press
    the button obviously, the textbox control will lose focus
    and the Button will get focus.

    As far as getting the text of the textbox is concerned, it
    can be done very easily by writing the event handler for
    Button's Click event as follows:

    private void Button1_Click(object sender,
    System.EventArgs e)
    {
    string Value;
    Value = TextBox1.Text;
    }

    Value will contain the text entered in the textbox.

    Regards,
    Vikram

    >-----Original Message-----
    >P.S. I need a C# solution. Thanks.
    >
    >
    >>-----Original Message-----
    >>I want to enter characters in a TextBox in a WebForm,
    >>press a Button in the WebForm, and read the characters
    >>that were typed into the TextBox from within the
    >>Button_Click event handler. The main point here is that

    I
    >>want to read the value typed into the TextBox without
    >>hitting the Enter key or setting focus on another
    >>control ...
    >>
    >>
    >>
    >>.
    >>

    >.
    >
     
    Vikram.NET, Jul 14, 2003
    #6
    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. Cindy
    Replies:
    2
    Views:
    11,417
    Charlie Nilsson [MSFT]
    Mar 3, 2004
  2. Rajen
    Replies:
    2
    Views:
    907
    Ben Pfaff
    Sep 9, 2006
  3. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    438
    Anders Matthiessen
    Jan 12, 2005
  4. GOKU24
    Replies:
    0
    Views:
    165
    GOKU24
    Aug 26, 2003
  5. HopfZ
    Replies:
    0
    Views:
    624
    HopfZ
    Aug 28, 2006
Loading...

Share This Page