By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,276 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,276 IT Pros & Developers. It's quick & easy.

OnLeave event on a textbox?

P: n/a
ML
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.
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You can do it on client side with an onblur event. What do you want to do on
this event?

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
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.

Nov 19 '05 #2

P: n/a
ML
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" <ML@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
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.


Nov 19 '05 #3

P: n/a
<asp:textbox id=TextBox1 ...
onblur="document.getElementById('TextBox2').disabl ed=(this.value=='')" ...

<asp:textbox id=TextBox2 ...

No server-side code is required.

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
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" <ML@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
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.


Nov 19 '05 #4

P: n/a
ML
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').disabl ed=(this.value=='')" ...

<asp:textbox id=TextBox2 ...

No server-side code is required.

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
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" <ML@discussions.microsoft.com> wrote in message
news:8D**********************************@microsof t.com...
> 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.


Nov 19 '05 #5

P: n/a
If the user enters something, you will get a server-side TextChanged event.
Is not it good for you?

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
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').disabl ed=(this.value=='')" ....
<asp:textbox id=TextBox2 ...

No server-side code is required.

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
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" <ML@discussions.microsoft.com> wrote in message
> news:8D**********************************@microsof t.com...
> > 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.
>
>
>


Nov 19 '05 #6

P: n/a
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" <ML@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
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').disabl ed=(this.value=='')"
...

<asp:textbox id=TextBox2 ...

No server-side code is required.

Eliyahu

"ML" <ML@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
> 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" <ML@discussions.microsoft.com> wrote in message
> > news:8D**********************************@microsof t.com...
> > > 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.
> >
> >
> >


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.