Professional Web Applications Themes

Get text in TextBox without pressing Enter key - ASP.NET General

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

  1. #1

    Default Get text in TextBox without pressing Enter key

    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 Guest

  2. #2

    Default Get text in TextBox without pressing Enter key

    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 Guest

  3. #3

    Default Re: Get text in TextBox without pressing Enter key

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

    [url]http://aspnetweblog.com/posts/7115.aspx[/url]


    "mg" <mgtheworld.com> wrote in message
    news:03e301c34a02$c5c555e0$a001280aphx.gbl...
    > 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 Guest

  4. #4

    Default Re: Get text in TextBox without pressing Enter key

    mg,

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

    You get the text with:

    MyTextBox.Text

    Justin


    "mg" <mgtheworld.com> wrote in message
    news:08b301c34a0a$a0993770$a301280aphx.gbl...
    > 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...
    > >
    > >[url]http://aspnetweblog.com/posts/7115.aspx[/url]
    > >
    > >
    > >"mg" <mgtheworld.com> wrote in message
    > >news:03e301c34a02$c5c555e0$a001280aphx.gbl...
    > >> 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 Guest

  5. #5

    Default Re: Get text in TextBox without pressing Enter key

    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" <gengojkrause.com> wrote in message
    news:vh5cvsfi1n7a91corp.supernews.com...
    > mg,
    >
    > Then the code that dj Bass just gave you is what you want.
    >
    > You get the text with:
    >
    > MyTextBox.Text
    >
    > Justin
    >
    >
    > "mg" <mgtheworld.com> wrote in message
    > news:08b301c34a0a$a0993770$a301280aphx.gbl...
    > > 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...
    > > >
    > > >[url]http://aspnetweblog.com/posts/7115.aspx[/url]
    > > >
    > > >
    > > >"mg" <mgtheworld.com> wrote in message
    > > >news:03e301c34a02$c5c555e0$a001280aphx.gbl...
    > > >> 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 Guest

  6. #6

    Default Get text in TextBox without pressing Enter key

    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 Guest

Similar Threads

  1. Pressing Enter s up my template - line breaksimages
    By layziebone123 in forum Macromedia Dynamic HTML
    Replies: 6
    Last Post: September 2nd, 12:52 PM
  2. input=text fires Submit when pressing Enter
    By Jerry in forum ASP.NET General
    Replies: 4
    Last Post: July 25th, 01:38 PM
  3. Textbox and button -- enter key/submit - REFERENCE
    By KathyB in forum ASP.NET General
    Replies: 0
    Last Post: July 24th, 10:24 PM
  4. Textbox, button and Enter on keyboard
    By DDK in forum ASP.NET General
    Replies: 2
    Last Post: July 16th, 01:38 PM
  5. Replies: 0
    Last Post: June 30th, 05:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139