Ajax Modal Popup Extender Problems

Joined
Mar 5, 2009
Messages
1
Reaction score
0
Hello

I am trying to make a automation system using modal popup extenders. The aim is having user controls loaded into modal popup extenders so that it actually feels like a forms application (customer request). I can properly open the first child modal popup extender but the second modal popup extender inside the first one is creating weird problems. Also I dont know how to close the modal popup extender from the user control loaded inside it. The following are my codes:

Default.aspx (HTML) (Page that contains the 1st modal popup)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Kararlar2.aspx.cs" Inherits="Kararlar2" EnableEventValidation="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<html xmlns="sees this as a link so i removed">
<head id="Head1" runat="server">
<title></title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>

<body>
<form id="Form1" runat=server>
<div style="float:left;height:100px; width: 100%; border:solid 1px black">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>

<div id="Div1" style="float:left;height:10px; width: 65%" runat="server">
<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtender3" TargetControlID="Button6"
PopupControlID="modalPanel3" OkControlID="Button6" EnableViewState=true
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:panel runat="server" ID="modalPanel3" BackColor="#FBEFEF" Style="display: none" EnableViewState=true>
<table width="100%" border="0">
<tr>
<td align="right">
<asp:ImageButton ID="Button6" runat="server" Height="15" Width="35"
ImageUrl="~/imgs/diger/buttone.jpg"/>
</td>
</tr>
<tr>
<td>
<asp:placeHolder ID="PlaceHolder1" runat="server"></asp:placeHolder>


</td>
</tr>
</table>
</asp:panel>
</div>
</div>
</form>
</body>
</html>

Codebehind for Default.aspx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
try
{
LoadUserControl();
}
catch { }
}

private void LoadUserControl()
{
string controlPath = LastLoadedControl;

if (!string.IsNullOrEmpty(controlPath))
{
UserControl uc = (UserControl)LoadControl(controlPath);
PlaceHolder1.Controls.Add(uc);
modalPopupExtender3.Show();
}
}
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}

protected void Button1_Click(object o, EventArgs e)
{

controlPath = "~/someusercontrol.ascx";

LastLoadedControl = controlPath;
LoadUserControl();

}

Now when I click on button1 on this page, I see my modal popup extender opening properly with state controls, no problems. But then inside the someusercontrol.ascx:

someusercontrol.ascx (HTML) (Usercontrol that contains the 2nd modal popup)

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="someusercontrol.ascx.cs" Inherits="someusercontrol" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


<div id="Div1" style="float:left;height:10px; width: 65%" runat="server">
<ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtender3" TargetControlID="Button6"
PopupControlID="modalPanel3" OkControlID="Button6" EnableViewState=true
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>
<asp:panel runat="server" ID="modalPanel3" BackColor="#FBEFEF" Style="display: none" EnableViewState=true>
<table width="100%" border="0">
<tr>
<td align="right">
<asp:ImageButton ID="Button6" runat="server" Height="15" Width="35"
ImageUrl="~/imgs/diger/buttone.jpg"/>
</td>
</tr>
<tr>
<td>
<asp:placeHolder ID="PlaceHolder1" runat="server"></asp:placeHolder>


</td>
</tr>
</table>
</asp:panel>
</div>

Codebehind for someusercontrol.ascx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;

public partial class someusercontrol : System.Web.UI.UserControl
{

protected void Page_Load(object sender, EventArgs e)
{
LoadUserControl();
}

protected void Button2_Click(object o, EventArgs e)
{
LastLoadedControl = "~/someusercontrol2.ascx";
LoadUserControl();
}

private void LoadUserControl()
{
string controlPath = LastLoadedControl;

if (!string.IsNullOrEmpty(controlPath))
{
UserControl uc = (UserControl)LoadControl(controlPath);
PlaceHolder1.Controls.Add(uc);
modalPopupExtender3.Show();
}
}
private string LastLoadedControl
{
get
{
return ViewState["LastLoaded"] as string;
}
set
{
ViewState["LastLoaded"] = value;
}
}



Strange thing is , in someusercontrol.ascx, if I copy/paste the lines of loadusercontrol method to pageload, someusercontrol2.ascx is visible as modal popup extender from load. But if i try to fire it later from button click, it doesnt work....

So summary of my questions:

1- Why does someusercontrol2.ascx cannot be shown in the modal popup extender present in someusercontrol1.ascx

2-How can I close the modal popup extender present in default.aspx from someusercontrol1.ascx

3-When someusercontrol2.ascx is shown (from page load) it does not center why ?

I appreciate any help and thanks a lot in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top