OnLeave event on a textbox?

Discussion in 'ASP .Net' started by =?Utf-8?B?TUw=?=, Sep 27, 2005.

  1. Hi NG,

    Can anyone tell me how to create a OnLeave event on a regular textbox in an
    ASP.NET webform? The only events I have available are: TextChanged, Disposed,
    Init, Load, Prerender and Unload..

    Thanks!

    regards,

    M.L.
    =?Utf-8?B?TUw=?=, Sep 27, 2005
    #1
    1. Advertising

  2. Hi,

    I want to disable another textbox in the same form if the user has entered
    anything into the first box. The OnLeave is needed to determine whether this
    is true. Like so:

    private void TextBox1_OnLeave()
    {
    if (TextBox1.Text.Length > 0)
    TextBox2.Enabled = false;
    }

    How can this be implemented?

    Thanks!

    "Eliyahu Goldin" wrote:

    > You can do it on client side with an onblur event. What do you want to do on
    > this event?
    >
    > Eliyahu
    >
    > "ML" <> wrote in message
    > news:...
    > > Hi NG,
    > >
    > > Can anyone tell me how to create a OnLeave event on a regular textbox in

    > an
    > > ASP.NET webform? The only events I have available are: TextChanged,

    > Disposed,
    > > Init, Load, Prerender and Unload..
    > >
    > > Thanks!
    > >
    > > regards,
    > >
    > > M.L.

    >
    >
    >
    =?Utf-8?B?TUw=?=, Sep 27, 2005
    #2
    1. Advertising

  3. Hi,

    Thanks very much for the solution, but in fact I would prefer to do it
    server-side.. Is this not possible?

    "Eliyahu Goldin" wrote:

    > <asp:textbox id=TextBox1 ...
    > onblur="document.getElementById('TextBox2').disabled=(this.value=='')" ...
    >
    > <asp:textbox id=TextBox2 ...
    >
    > No server-side code is required.
    >
    > Eliyahu
    >
    > "ML" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I want to disable another textbox in the same form if the user has entered
    > > anything into the first box. The OnLeave is needed to determine whether

    > this
    > > is true. Like so:
    > >
    > > private void TextBox1_OnLeave()
    > > {
    > > if (TextBox1.Text.Length > 0)
    > > TextBox2.Enabled = false;
    > > }
    > >
    > > How can this be implemented?
    > >
    > > Thanks!
    > >
    > > "Eliyahu Goldin" wrote:
    > >
    > > > You can do it on client side with an onblur event. What do you want to

    > do on
    > > > this event?
    > > >
    > > > Eliyahu
    > > >
    > > > "ML" <> wrote in message
    > > > news:...
    > > > > Hi NG,
    > > > >
    > > > > Can anyone tell me how to create a OnLeave event on a regular textbox

    > in
    > > > an
    > > > > ASP.NET webform? The only events I have available are: TextChanged,
    > > > Disposed,
    > > > > Init, Load, Prerender and Unload..
    > > > >
    > > > > Thanks!
    > > > >
    > > > > regards,
    > > > >
    > > > > M.L.
    > > >
    > > >
    > > >

    >
    >
    >
    =?Utf-8?B?TUw=?=, Sep 27, 2005
    #3
  4. You can do it on client side with an onblur event. What do you want to do on
    this event?

    Eliyahu

    "ML" <> wrote in message
    news:...
    > Hi NG,
    >
    > Can anyone tell me how to create a OnLeave event on a regular textbox in

    an
    > ASP.NET webform? The only events I have available are: TextChanged,

    Disposed,
    > Init, Load, Prerender and Unload..
    >
    > Thanks!
    >
    > regards,
    >
    > M.L.
    Eliyahu Goldin, Sep 27, 2005
    #4
  5. <asp:textbox id=TextBox1 ...
    onblur="document.getElementById('TextBox2').disabled=(this.value=='')" ...

    <asp:textbox id=TextBox2 ...

    No server-side code is required.

    Eliyahu

    "ML" <> wrote in message
    news:...
    > Hi,
    >
    > I want to disable another textbox in the same form if the user has entered
    > anything into the first box. The OnLeave is needed to determine whether

    this
    > is true. Like so:
    >
    > private void TextBox1_OnLeave()
    > {
    > if (TextBox1.Text.Length > 0)
    > TextBox2.Enabled = false;
    > }
    >
    > How can this be implemented?
    >
    > Thanks!
    >
    > "Eliyahu Goldin" wrote:
    >
    > > You can do it on client side with an onblur event. What do you want to

    do on
    > > this event?
    > >
    > > Eliyahu
    > >
    > > "ML" <> wrote in message
    > > news:...
    > > > Hi NG,
    > > >
    > > > Can anyone tell me how to create a OnLeave event on a regular textbox

    in
    > > an
    > > > ASP.NET webform? The only events I have available are: TextChanged,

    > > Disposed,
    > > > Init, Load, Prerender and Unload..
    > > >
    > > > Thanks!
    > > >
    > > > regards,
    > > >
    > > > M.L.

    > >
    > >
    > >
    Eliyahu Goldin, Sep 27, 2005
    #5
  6. If the user enters something, you will get a server-side TextChanged event.
    Is not it good for you?

    Eliyahu

    "ML" <> wrote in message
    news:...
    > Hi,
    >
    > Thanks very much for the solution, but in fact I would prefer to do it
    > server-side.. Is this not possible?
    >
    > "Eliyahu Goldin" wrote:
    >
    > > <asp:textbox id=TextBox1 ...
    > > onblur="document.getElementById('TextBox2').disabled=(this.value=='')"

    ....
    > >
    > > <asp:textbox id=TextBox2 ...
    > >
    > > No server-side code is required.
    > >
    > > Eliyahu
    > >
    > > "ML" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > I want to disable another textbox in the same form if the user has

    entered
    > > > anything into the first box. The OnLeave is needed to determine

    whether
    > > this
    > > > is true. Like so:
    > > >
    > > > private void TextBox1_OnLeave()
    > > > {
    > > > if (TextBox1.Text.Length > 0)
    > > > TextBox2.Enabled = false;
    > > > }
    > > >
    > > > How can this be implemented?
    > > >
    > > > Thanks!
    > > >
    > > > "Eliyahu Goldin" wrote:
    > > >
    > > > > You can do it on client side with an onblur event. What do you want

    to
    > > do on
    > > > > this event?
    > > > >
    > > > > Eliyahu
    > > > >
    > > > > "ML" <> wrote in message
    > > > > news:...
    > > > > > Hi NG,
    > > > > >
    > > > > > Can anyone tell me how to create a OnLeave event on a regular

    textbox
    > > in
    > > > > an
    > > > > > ASP.NET webform? The only events I have available are:

    TextChanged,
    > > > > Disposed,
    > > > > > Init, Load, Prerender and Unload..
    > > > > >
    > > > > > Thanks!
    > > > > >
    > > > > > regards,
    > > > > >
    > > > > > M.L.
    > > > >
    > > > >
    > > > >

    > >
    > >
    > >
    Eliyahu Goldin, Sep 27, 2005
    #6
  7. =?Utf-8?B?TUw=?=

    Marina Guest

    No. This event happens on the client in the browser. The server is on the
    othe rend of the wire - it has no idea that the user switched focus to a
    different field.

    You can trigger a postback to the server - but you would still need client
    side code to trigger this. And then your page looks ugly because it keeps
    flashing.

    "ML" <> wrote in message
    news:...
    > Hi,
    >
    > Thanks very much for the solution, but in fact I would prefer to do it
    > server-side.. Is this not possible?
    >
    > "Eliyahu Goldin" wrote:
    >
    >> <asp:textbox id=TextBox1 ...
    >> onblur="document.getElementById('TextBox2').disabled=(this.value=='')"
    >> ...
    >>
    >> <asp:textbox id=TextBox2 ...
    >>
    >> No server-side code is required.
    >>
    >> Eliyahu
    >>
    >> "ML" <> wrote in message
    >> news:...
    >> > Hi,
    >> >
    >> > I want to disable another textbox in the same form if the user has
    >> > entered
    >> > anything into the first box. The OnLeave is needed to determine whether

    >> this
    >> > is true. Like so:
    >> >
    >> > private void TextBox1_OnLeave()
    >> > {
    >> > if (TextBox1.Text.Length > 0)
    >> > TextBox2.Enabled = false;
    >> > }
    >> >
    >> > How can this be implemented?
    >> >
    >> > Thanks!
    >> >
    >> > "Eliyahu Goldin" wrote:
    >> >
    >> > > You can do it on client side with an onblur event. What do you want
    >> > > to

    >> do on
    >> > > this event?
    >> > >
    >> > > Eliyahu
    >> > >
    >> > > "ML" <> wrote in message
    >> > > news:...
    >> > > > Hi NG,
    >> > > >
    >> > > > Can anyone tell me how to create a OnLeave event on a regular
    >> > > > textbox

    >> in
    >> > > an
    >> > > > ASP.NET webform? The only events I have available are: TextChanged,
    >> > > Disposed,
    >> > > > Init, Load, Prerender and Unload..
    >> > > >
    >> > > > Thanks!
    >> > > >
    >> > > > regards,
    >> > > >
    >> > > > M.L.
    >> > >
    >> > >
    >> > >

    >>
    >>
    >>
    Marina, Sep 27, 2005
    #7
    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. jorge
    Replies:
    2
    Views:
    1,251
    jorge
    May 26, 2004
  2. =?Utf-8?B?QmVuIEZpZGdl?=

    Is there a client-side OnLeave event for a page?

    =?Utf-8?B?QmVuIEZpZGdl?=, Feb 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    592
    Karl Seguin [MVP]
    Feb 13, 2006
  3. Thomas Henz

    onleave?

    Thomas Henz, Sep 7, 2003, in forum: HTML
    Replies:
    11
    Views:
    4,853
    Darren Benfer
    Sep 8, 2003
  4. S_K
    Replies:
    6
    Views:
    1,160
    Robert Dunlop
    Nov 8, 2007
  5. jorge
    Replies:
    1
    Views:
    403
    Teemu Keiski
    May 28, 2004
Loading...

Share This Page