Calling JavaScript from

Most of we think that it is very difficult to call a javascript code from
codebehind file in But it is possible with a single line of code….
Let me explain to display a confirmation dialog box in a page…
If we have a button named Button1 then
  in Page_Load  add the following single statement
    Button1.attributes.add("onclick","if (confirm(‘Are you sure to proceed?’)) return true;else return false;")
       That’s it. Our job is done..
Now we can write the server side coding in Button1_Click that shud be executed if user clicks "yes"
      on the prompt. It won’t do the postback if we go with "No" option

One Comment on “Calling JavaScript from”

  1. sillygloop says:

    Wandered onto ur page n thought I\’d invite u to come check my computer program cartoons at when u find time. Blog on…n have a nice day!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s