Community discussion forum

Add a JavaScript popup to an ASP.NET button

This is a comment thread discussing Add a JavaScript popup to an ASP.NET button
  • 10 years ago

    This thread is for discussions of Add a JavaScript popup to an ASP.NET button.

  • 5 years ago

    It's very useful and pratical,
    but a little short and simple

  • 5 years ago

    Exactly what I needed to get started.  Thanks, Ed.

  • 4 years ago

    sometimes it is neccessary to add return value otherwise the code behind event will be executed.


    if (confirm("Are you sure ?") == false)
    {
     window.event.returnValue = false;
     return false;
    }
    else
    {
     window.event.returnValue = true;
     return true;
    }

  • 4 years ago

    "btnSubmit_Click" (The method in the code behind) needs to have public permissions

  • 4 years ago

    HI,
    this is good code
    I like it.
    but you dint mention that what name space need to use for stringbuild ????


    any way I used this   using System.Te

  • 3 years ago

    Your code will execute the onclick event twice!

    You need to remove the onclick event specified in html.

     

  • 2 years ago

    Another way to get popup is to write the scripts right inside the header as below.

    <HEAD>
    <script type="text/javascript" language="JavaScript">
    function openph(url)
    {
    var url1 = url;
    window.open(url1, "","top=0,left=0,menubar=no,toolbar=no,location=no,resizable=no,height=550,width=440,status=no,scrollbars=no,maximize=null,resizable=0,titlebar=no;");
    }
    </script>






     

    Call any function from the code behind using the following

    Dim st As String = "<script language='javascript'>" & _

    "openph('Enlargephoto.aspx')" & _

    "</script>"

    Call this from a button click like this.

    Private

    Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

    Page.RegisterStartupScript("poscript", st)

    End Sub

  • 1 year ago

    IE7 (Vista) has problems with the java confirm script in this form. After a lot of testing and research we came to this sollution that works for IE7 (Vista), IE (other), Firefox

     

    if(confirm(\"Are You Sure\")==false){ try{window.event.returnValue = false;}catch(err){}return false; };"); 

     

    the "try catch" is because -- "window.event.returnValue = false;" -- gives problems in firefox (and firefox based browsers)

    Hope this help everyone with the same problem (and wants to update for the new Microsoft(c) Vista(c) Errors(c) )

     

    Michiel 

  • 7 months ago
    Hi,I’m just wondering, how do you go around the EvaluateEvent error? It appears that by default on click events are evaulated by the .NET Runtime, and this traps my On Client Click event. If I set it to false craps gambling, some of the events on my page won’t be processed properly. How do you go about that?

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!