JavaScript On Post Back

T

thomson

Hi All,
I do have a button control, which has a post back and has to do
some server side validations also.

I need to attach some client side scripting also , where it can be
called only on the post back

For eg:

In the click of the server side control, i do some validations
and i have to show an alert button. This thing i achieved, but the
problem is that while iam viewing the alert button, i see a blank page,
because it is in the middle of the post back. while i say OK to the
alert button, i can see the controls in the form.

One thing i have to clarify is that the alert message can only be known
on the post back, but i dont want to see the blank page


Thanks in Advance

thomson
 
G

garethdjames

this should work

place this in the button event handler or page_load (with
Page.isPostback)

if(Page.IsValid)
{
this.RegisterStartupScript( "script", "<script
language=javascript>alert('hello');</script>");
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top