We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

More AJAX ModalPopup Questions (with MasterPages)

Howard Bash
Howard Bash asked
on
Medium Priority
1,245 Views
Last Modified: 2012-06-21
I have created a master page and put a modalpopup, the associated panel, and dummy control, and am trying to launch it on a form's button click.  The click event is called (a small javascript routine),  but it does not finc the popup to tell it to "Show".

I have included all the code fragments.  Pretty much everything is in the master page and the buttons appear and when I click the button on the default.aspx page I get the message that the javascript routine is being called, but the modalExtenderPopup id is not being found.
'SiteMaster.Master'
<%@ Master Language="VB" CodeFile="SiteMaster.master.vb" Inherits="SiteMaster" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    
<link href="css/SiteStyleSheet.css" rel="stylesheet" type="text/css" />
 
<link href="css/ModalPopupStyles.css" rel="stylesheet" type="text/css" />
   
<script language="javascript" type="text/javascript">
 
function HideModalPopup() 
{ 
  var modal = $find('mpe'); 
  if(modal)
  {
    modal.hide(); 
  }
  else
  {
  alert('Cannot find modal');
  }
}
 
function ShowMyModalPopup() 
{ 
  alert ('Hi');
 var modal = $find('mpe'); 
  if(modal)
  {
   modal.show(); 
  }
  else
  {
  alert('Cannot find modal');
  }
}
 
function fnClickUpdate(sender, e) 
{ 
  __doPostBack(sender,e); 
}
 
</script>   
    
</head>
<body>
 
    <form id="form1" runat="server">
    
    
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        
    <div>
        <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
        
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Height="485px" Width="645px" style="display:none">
 
    <center>
    <br />
    <IFRAME id="frame1" width="640px" height="480px" scrolling="auto" runat="server">
    </IFRAME>
    </center>
 
    <asp:Button ID="Button1" runat="server" Text="OK" /> 
    <asp:Button ID="Button2" runat="server" Text="Cancel" /> 
 
</asp:Panel>
 
<asp:Button runat="server" ID="txtDummy" style="display:none"  />
<ajaxToolkit:ModalPopupExtender  ID="mpe" runat="server"    
    TargetControlID="txtDummy"
    PopupControlID="Panel1"
    OkControlID="Button1"
    CancelControlID="Button2" 
    DropShadow="true"
    BackgroundCssClass="modalBackground"
    RepositionMode="RepositionOnWindowResize">
    
</ajaxToolkit:ModalPopupExtender>
 
<br />
        
</asp:contentplaceholder>
    </div>
    
<Button ID="cmdShowPage" value ="A Button" title="Buttonie" type="button" onclick="ShowMyModalPopup();">
    Abutton</Button><br />
    
    </form>
    
</body>
</html>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Modal Popup Styles Style Sheet
*Modal Popup*/
.modalBackground {
	background-color:Gray;
	filter:alpha(opacity=70);
	opacity:0.7;
}
 
.modalPopup {
	background-color:#ffffdd;
	border-width:3px;
	border-style:solid;
	border-color:Gray;
	padding:3px;
	width:250px;
}
 
 
.modalPanelAsTable TABLE
   {
      border: #060F40 2px solid;
      color: #060F40;
      background: #ffffcc;
   }
 
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Open in new window

Comment
Watch Question

Analyst Programmer
Commented:

add a BehaviorID to your modal popup.
could try BehaviorID="mpe" so you wont have to change anything
 
from http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/ExtenderClasses.aspx
  • BehaviorID: In cases where you would like to access the client-side behavior for your extender from script code in the client, you can set this BehaviorID to simplify the process.  See example below:
  • <ns:MyExtender ID="myExtender1"
    runat="server" TargetControlID="Button1" BehaviorID="myBehavior1" />
    <script type="text/javascript">
    function changeValue() {
    var myBehavior = $find("myBehavior1");
    myBehavior.set_Value(0);
    }
    </script>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.