AJAX: ModalPopupExtender activation

Ho do you programmaticaly activate a AJAX ModalPopupExtender

Page 1 of 1

5 Replies - 61601 Views - Last Post: 17 February 2010 - 11:12 AM Rate Topic: -----

#1 dwatling   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-June 07

AJAX: ModalPopupExtender activation

Posted 28 June 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?

		<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 June 2007 - 04:05 AM


Is This A Good Question/Topic? 0
  • +

Replies To: AJAX: ModalPopupExtender activation

#2 pkitty   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-July 07

Re: AJAX: ModalPopupExtender activation

Posted 10 July 2007 - 05:35 AM

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:

<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:

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

View Postdwatling, on 28 Jun, 2007 - 03:57 AM, said:

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?

		<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>



Was This Post Helpful? 0
  • +
  • -

#3 dan8ny   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-September 07

Re: AJAX: ModalPopupExtender activation

Posted 18 September 2007 - 12:34 PM

You can use the Show() and Hide() methods in the server-side codebehind for the modal popup extender.
Was This Post Helpful? 0
  • +
  • -

#4 pkitty   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-July 07

Re: AJAX: ModalPopupExtender activation

Posted 18 September 2007 - 12:43 PM

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.
Was This Post Helpful? 0
  • +
  • -

#5 avolel   User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 42
  • Joined: 24-August 05

Re: AJAX: ModalPopupExtender activation

Posted 27 November 2007 - 10:19 AM

View Postdwatling, on 28 Jun, 2007 - 03:57 AM, said:

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?

		<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.
Was This Post Helpful? 1

#6 Guest_Joe Rocker*


Reputation:

Re: AJAX: ModalPopupExtender activation

Posted 17 February 2010 - 11:12 AM

Thanks alot. I knew you could do it, but I couldn't figure out how.
Was This Post Helpful? 0

Page 1 of 1