Welcome to Dream.In.Code
Become an Expert!

Join 149,523 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,427 people online right now. Registration is fast and FREE... Join Now!




AJAX: ModalPopupExtender activation

 
Reply to this topicStart new topic

AJAX: ModalPopupExtender activation, Ho do you programmaticaly activate a AJAX ModalPopupExtender

dwatling
28 Jun, 2007 - 02:57 AM
Post #1

New D.I.C Head
*

Joined: 28 Jun, 2007
Posts: 1


My Contributions
I have a page with a ModalPopupExtender that I would like to show (or not) based on a QueryString value when the page loads. It works fine when clicking on a botton to activate it. I am working in VB.

Ho do I either:
1) Programmaticaly "click" the botton
or
2) Programatically "show" the ModalPopupExtender?

CODE

        <asp:Panel ID="DualLoginAtempt" runat="server" Height="300px" Width="300px" CssClass="modalPopup">
            <div class="center"><h2>Another user is already logged in on this account</h2>
            This account will be locked for 1 hour.<br />
            <br />
        <asp:Button ID="btnDualLoginAtempt" runat="server" Text="Close" /></div></asp:Panel>
        <asp:Button ID="popDualLoginAtempt" runat="server" Text="Dual Login Atempt" Visible="True" />
        <cc1:ModalPopupExtender ID="mpeDualLoginAtempt" runat="server"
            TargetControlID="popDualLoginAtempt"
            PopupControlID="DualLoginAtempt"
            CancelControlID="btnDualLoginAtempt"
            BackgroundCssClass="modalBackground"
        >
        </cc1:ModalPopupExtender>



This post has been edited by dwatling: 28 Jun, 2007 - 03:05 AM
User is offlineProfile CardPM
+Quote Post

pkitty
RE: AJAX: ModalPopupExtender Activation
10 Jul, 2007 - 04:35 AM
Post #2

New D.I.C Head
*

Joined: 10 Jul, 2007
Posts: 2


My Contributions
Hi dwatling! My first post here, but I'm quite adept at working with the AJAX framework and AJAX Control Toolkit. Oneway to show your modal popup is done from the client-side using javascript.

Your modal popup extender (mpe) has a property called "BehaviorID" - if you would like to control the behavior of the mpe via javascript, you will need to set this property. As a rule of thumb, I set my BehaviorID property to the same value as the ID property. After adding this value, your mpe markup will be as such:

CODE

<cc1:ModalPopupExtender ID="mpeDualLoginAtempt" runat="server"
    BehaviorID="mpeDualLoginAtempt"
    TargetControlID="popDualLoginAtempt"
    PopupControlID="DualLoginAtempt"
    CancelControlID="btnDualLoginAtempt"
    BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>


After setting this property, you can then reference this control via javascript. Based on your code below, pressing the "popDualLoginAtempt" button will automatically make the modal popup appear; however, to programatically make the panel popup, use the following java script:

CODE

function DisplayModalPopup() {
  // get reference to modal popup using the AJAX api $find() function
  // this funciton gets a reference to a ajax control toolkit object if the behavior
  // id property is specified
  var mpe = $find('mpeDualLoginAtempt');
  if (mpe) {
    mpe.show();
  }
}


Each control in the control toolkit has methods available for client-side development. I recommend downloading the source code for the AJAX Control Toolkit and explore the accompanying .js files for the control you're working with.

-pk

QUOTE(dwatling @ 28 Jun, 2007 - 03:57 AM) *

I have a page with a ModalPopupExtender that I would like to show (or not) based on a QueryString value when the page loads. It works fine when clicking on a botton to activate it. I am working in VB.

Ho do I either:
1) Programmaticaly "click" the botton
or
2) Programatically "show" the ModalPopupExtender?

CODE

        <asp:Panel ID="DualLoginAtempt" runat="server" Height="300px" Width="300px" CssClass="modalPopup">
            <div class="center"><h2>Another user is already logged in on this account</h2>
            This account will be locked for 1 hour.<br />
            <br />
        <asp:Button ID="btnDualLoginAtempt" runat="server" Text="Close" /></div></asp:Panel>
        <asp:Button ID="popDualLoginAtempt" runat="server" Text="Dual Login Atempt" Visible="True" />
        <cc1:ModalPopupExtender ID="mpeDualLoginAtempt" runat="server"
            TargetControlID="popDualLoginAtempt"
            PopupControlID="DualLoginAtempt"
            CancelControlID="btnDualLoginAtempt"
            BackgroundCssClass="modalBackground"
        >
        </cc1:ModalPopupExtender>




User is offlineProfile CardPM
+Quote Post

dan8ny
RE: AJAX: ModalPopupExtender Activation
18 Sep, 2007 - 11:34 AM
Post #3

New D.I.C Head
*

Joined: 18 Sep, 2007
Posts: 1


My Contributions
You can use the Show() and Hide() methods in the server-side codebehind for the modal popup extender.
User is offlineProfile CardPM
+Quote Post

pkitty
RE: AJAX: ModalPopupExtender Activation
18 Sep, 2007 - 11:43 AM
Post #4

New D.I.C Head
*

Joined: 10 Jul, 2007
Posts: 2


My Contributions
Very true, but I think that the immediate client-side response is more efficient than either doing a postback or an AJAX callback within an update panel is this circumstance.
User is offlineProfile CardPM
+Quote Post

avolel
RE: AJAX: ModalPopupExtender Activation
27 Nov, 2007 - 09:19 AM
Post #5

New D.I.C Head
*

Joined: 24 Aug, 2005
Posts: 38



Thanked: 1 times
My Contributions
QUOTE(dwatling @ 28 Jun, 2007 - 03:57 AM) *

I have a page with a ModalPopupExtender that I would like to show (or not) based on a QueryString value when the page loads. It works fine when clicking on a botton to activate it. I am working in VB.

Ho do I either:
1) Programmaticaly "click" the botton
or
2) Programatically "show" the ModalPopupExtender?

CODE

        <asp:Panel ID="DualLoginAtempt" runat="server" Height="300px" Width="300px" CssClass="modalPopup">
            <div class="center"><h2>Another user is already logged in on this account</h2>
            This account will be locked for 1 hour.<br />
            <br />
        <asp:Button ID="btnDualLoginAtempt" runat="server" Text="Close" /></div></asp:Panel>
        <asp:Button ID="popDualLoginAtempt" runat="server" Text="Dual Login Atempt" Visible="True" />
        <cc1:ModalPopupExtender ID="mpeDualLoginAtempt" runat="server"
            TargetControlID="popDualLoginAtempt"
            PopupControlID="DualLoginAtempt"
            CancelControlID="btnDualLoginAtempt"
            BackgroundCssClass="modalBackground"
        >
        </cc1:ModalPopupExtender>




mpeDualLoginAtempt.Show() from the code behind to programmatically show your modal popup.
or
var modal = $find('mpeDualLoginAtempt');
modal.show();

to show your modal popup from javascript.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month