How to invoke a popup programmatically using Ajax Modal or anything else.

Last post 09-19-2009 4:33 PM by baboso#4. 6 replies.

Sort Posts:

  • How to invoke a popup programmatically using Ajax Modal or anything else.

    03-08-2009, 5:59 PM
    • Member
      64 point Member
    • baboso#4
    • Member since 07-07-2006, 8:56 PM
    • Posts 97

    My problem is this:   I want to use the modal Ajax popup.  I know how to use it, however, I want to be able to invoke it without having to attach it to a button control.  I want to be able to call the modal extender and display it.  Perhaps there is another way to do this without using the Ajax extender.

    Should I be displaying the Panel that is attached to the extender instead.  You would figure that by now we'd have an equivalent of MessageBox in ASP.Net.

      I have tried creating a delegate to handle the button event so it can then  use the extender to no avail.

      Any suggestions?

  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    03-08-2009, 8:38 PM
    You don't have to do it using button click. Yoou can do it in Page_Load if you want. Yo would use YourModalExtenderID.Show().
  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    03-08-2009, 9:58 PM
    • Star
      10,558 point Star
    • Danny117
    • Member since 12-16-2008, 2:30 PM
    • Royal Oak Michigan USA
    • Posts 1,837

    Simplest is to code a behaviorid into the extender and then use $find("behaviorid").show(); on javascript click.

    <%--modal poup markup--%>

    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"

    BehaviorID="CMX"

    ...

    </cc1:ModalPopupExtender>

    //javascript now I can just show it from anywhere.

    $find("CMX").show();

    Another live demo of course just click on the comments link at the end of the post.  Your welcome to lift the source and javascript from .axd

    http://www.gosylvester.com/blog.aspx?id=44 

    Good Luck



  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    03-09-2009, 1:02 AM
    • Member
      64 point Member
    • baboso#4
    • Member since 07-07-2006, 8:56 PM
    • Posts 97

    I don't think either answer works well.   The extender.show has a weird behavior.  It displays the extender's panel for a fraction of a second the first time you bring the page up and you still have to assign a button control to the extender which decieves the purpose.  You still have to do the same thing for the second solution and if you make the button invisible so it doesn't get used, then the extender doesn't work.

     Thanks anyway.  I just thought there was an easy way to dispplay a modal popup without having to click a darn button or go to the extreme of having to create your own control.  It's so much easier in windows forms with the MessageBox.  I could just create a javascript alert to be called on a condition which is what I was trying to get to.

  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    03-09-2009, 1:11 AM
    Answer
    • Star
      10,558 point Star
    • Danny117
    • Member since 12-16-2008, 2:30 PM
    • Royal Oak Michigan USA
    • Posts 1,837

    You maybe want a confirm extender.  It makes a simple message box.  Click ok it posts back.  Click cancel it doesn't.

    <asp:Button ID="Button1" runat="server" Text="Send" />
        <cc1:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server"
            ConfirmText="Please allow some time for me to receive you email." Enabled="True" TargetControlID="Button1">
        </cc1:ConfirmButtonExtender>

    Good Luck with whatever it is you need.

     

    Good Luck



  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    06-13-2009, 9:34 AM
    • Member
      11 point Member
    • clduvall
    • Member since 05-28-2009, 2:49 PM
    • Posts 20
    In page load:

    If Not Page.IsPostBack Then pnlModal.Style.Value = "display: none;" End If

    That should fix the "Flicker" when you first load your page. pnlModal is the target panel of the modal extender.
  • Re: How to invoke a popup programmatically using Ajax Modal or anything else.

    09-19-2009, 4:33 PM
    • Member
      64 point Member
    • baboso#4
    • Member since 07-07-2006, 8:56 PM
    • Posts 97

    I wanted to revisit my own post to add this for those using AJAX with an Update Panel requirying just an alert.  The below statement works fine.  Probably even better if used with a delegate by which you can just pass a string.

    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "AlertBox", "alert('Please select a valid project');", true);

Page 1 of 1 (7 items)