Showing posts with label situation. Show all posts
Showing posts with label situation. Show all posts

Monday, March 26, 2012

Modal Popup extender need help PLEASE - URGENT

I am having quite an issue with the modal popup extender, and I fear my situation is very unique.

I have an aspx page that has 2 update panels. The first update panel contains a dropdown box with a list of locations, I'll call this UPD1. The second update panel contains a webpart that contains a user control that lists contact information for the location selected, I'll call this UPD2. On this user control is a modal popup ajax control that displays a dialog to add new contacts for the location and it is loaded by clicking a button. When the page is first displayed and I click the add button in UPD2 the modal dialog displays just fine. If I change the loaction in UPD1, which causes UPD2 to be updated with contact information for the new location selected in UPD1 the add button in UPD2 no loger displays the modal dialog, but, causes a postback.

If I change the page containg these 2 update panels and remove the webpart from UPD2 and just place gthe user control in UPD2 the page works fine.

Any ideas? I am really stuck on this one.

Thanks,

Here as my user control.ascx code

<%@.ControlLanguage="VB"

AutoEventWireup="false"

CodeFile="NotificationList.ascx.vb"

Inherits="NotificationList"

%>

<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<%@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI"TagPrefix="asp" %>

<scripttype="text/javascript">

var vClearFields;

function fLoadRecipDialog(vNotificationID)

{

var vFirstName = document.getElementById("CMNFirstName" + vNotificationID);

alert ("vFirstName Is " + vFirstName);

alert ("vFirstName Value Is " + vFirstName.value);

var vLastName = document.getElementById("CMNLastName" + vNotificationID);

var vTitle = document.getElementById("CMNTitle" + vNotificationID);

var vEMail = document.getElementById("CMNEMail" + vNotificationID);

var vFrequency = document.getElementById("CMNFrequency" + vNotificationID);

var vFirstNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipFirstName");

vFirstNameField.value = vFirstName.value;

var vLastNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipLastName");

vLastNameField.value = vLastName.value;

var vTitleField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipTitle");

vTitleField.value = vTitle.value;

var vEMailField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipEMail");

vEMailField.value = vEMail.value;

var vFrequencyField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_drpFrequency");

vFrequencyField.selectedIndex = parseFloat(vFrequency.value) - 1;

var vNotificationIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnNotificationID");

vNotificationIDField.value = vNotificationID;

vClearFields="N";

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_btnAddRecipient").click();

}

function fClearFields()

{

if (vClearFields !="N")

{

var vFirstNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipFirstName");

vFirstNameField.value ="";

var vLastNameField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipLastName");

vLastNameField.value ="";

var vTitleField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipTitle");

vTitleField.value ="";

var vEMailField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_txtRecipEMail");

vEMailField.value ="";

var vFrequencyField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_drpFrequency");

vFrequencyField.selectedIndex = parseFloat("0");

var vNotificationID = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnNotificationID");

vNotificationID.value ="0";

}

// vTestObject = $find("TestExtender");

// alert(vTestObject);

// vTestObject.show();

vClearFields="Y";

returnfalse;

}

function fSaveRecip()

{

var vActionField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnAction");

var vIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList1_hdnID");

vActionField.value ="Save";

vIDField.value ="";

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_lnkDoPost").click();

}

function fDeleteRecip(vID)

{

var vActionField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnAction");

var vIDField = document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_hdnID");

vActionField.value ="Delete";

vIDField.value = vID;

document.getElementById("WebPartManager1_gwpNotificationList_NotificationList_lnkDoPost").click();

}

</script>

<divclass="wpContent">

<asp:TableID="tblNotifications"runat="server"BorderStyle="solid"BorderWidth="1"Width="100%">

</asp:Table>

<center>

<asp:ButtonID="btnAddRecipient"runat="server"Text="Add"onclientclick='javascript: return fClearFields();'/>

<asp:LinkButtonID="lnkDoPost"runat="server"></asp:LinkButton>

<asp:LabelID="LabelCausedRefresh"runat="server"Width="184px"></asp:Label>

<asp:HiddenFieldID="hdnAction"runat="server"/>

<asp:HiddenFieldID="hdnID"runat="server"/>

</center>

<cc1:ModalPopupExtenderBehaviorID="TestExtender"ID="ModalPopupExtender1"runat="server"TargetControlID="btnAddRecipient"popupControlID="modalPanel"BackgroundCssClass="modalBackground"DropShadow="true"OkControlID="btnRecipSave"OnOkScript="fSaveRecip()"CancelControlID="btnRecipClose">

</cc1:ModalPopupExtender>

<divclass="modalPanel"id="modalPanel"style="display: none">

<asp:PanelID="pnlAddRecipient"runat="server"BorderWidth="1"Width="368px">

<tableborder="0"width="100%">

<tr>

<tdcolspan="2"align="center">

<b>Location Management - Notification Recipient</b>

</td>

</tr>

<tr>

<td>

</td>

<td>

</td>

</tr>

<tr>

<td>

<b>Location:</b>

</td>

<td>

<asp:LabelID="lblRecipLocationName"runat="server"Text="Label"Width="208px"></asp:Label>

</td>

</tr>

<tr>

<td>

<b>Name:</b>

</td>

<tdstyle="height: 26px">

<asp:TextBoxID="txtRecipFirstName"runat="server"Width="72px"></asp:TextBox>

<asp:TextBoxID="txtRecipLastName"runat="server"Width="128px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>Title:</b>

</td>

<td>

<asp:TextBoxID="txtRecipTitle"runat="server"Width="210px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>E-mail:</b>

</td>

<td>

<asp:TextBoxID="txtRecipEMail"runat="server"Width="210px"></asp:TextBox>

</td>

</tr>

<tr>

<td>

<b>Frequency:</b>

</td>

<td>

<asp:DropDownListID="drpFrequency"runat="server">

<asp:ListItemValue="1">Weekly</asp:ListItem>

<asp:ListItemValue="2">Bi-Weekly</asp:ListItem>

<asp:ListItemValue="3">Monthly</asp:ListItem>

</asp:DropDownList></td>

</tr>

<tr>

<tdcolspan="2"align="center">

<asp:LinkButtonID="btnRecipSave"runat="server">Save</asp:LinkButton>

<asp:LinkButtonID="btnRecipClose"runat="server">Close</asp:LinkButton>

<asp:HiddenFieldID="hdnNotificationID"runat="server"></asp:HiddenField>

</td>

</tr>

</table>

</asp:Panel>

</div>

</div>


Here is my ascx.vb code

Imports System.Data.SqlClient

Imports System.Data.OleDb

PartialClass NotificationList

Inherits System.Web.UI.UserControl

Dim cnRetailCommerceAs SqlConnection =Nothing

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

Dim dsConsManageAsNew System.Data.DataSet

Dim cmdSelectAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim daConsManageAsNew SqlDataAdapter

Dim tblRowAs TableRow

Dim tblCellAs TableCell

Dim m_aryFrequencies(3)AsString

m_aryFrequencies(1) ="Weekly"

m_aryFrequencies(2) ="Bi-Weekly"

m_aryFrequencies(3) ="Monthly"

LabelCausedRefresh.Text = Request.Form("__EventTarget")cnRetailCommerce =New SqlConnection(Session("CONNECTION"))

cnRetailCommerce.Open()

IfMe.IsPostBackThen

If Request.Form("__EventTarget").Contains("lnkDoPost")Then

SelectCase hdnAction.Value

Case"Delete"

DeleteConManageLocNotification()

Case"Save"

If hdnNotificationID.Value.ToString ="0"Then

CreateConManageLocNotification()

Else

UpdateConManageLocNotification()

EndIf

EndSelect

EndIf

EndIf

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

cmdSelect.Connection = cnRetailCommerce

cmdSelect.CommandType = Data.CommandType.StoredProcedure

cmdSelect.CommandText ="USP_CONSMANAGEGETLOCNOTIFICATIONS"

cmdSelect.Parameters.Add(parmCLocation)

daConsManage.SelectCommand = cmdSelect

daConsManage.Fill(dsConsManage,"Notifications")

Dim dvConsManageAsNew System.Data.DataView(dsConsManage.Tables("Notifications"))

Dim drRowAs System.Data.DataRow

dvConsManage.RowFilter ="EMail='" & Session("EMAIL").ToString &"'"

If dvConsManage.Count = 0Then

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text =" "

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fLoadRecipDialog(" & Chr(34) &"0" & Chr(34) &");'>Add Me</a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<input type='hidden' name='CMNFirstName0' id='CMNFirstName0' value='" & Session("FIRSTNAME") &"'><input type='hidden' name='CMNLastName0' id='CMNLastName0' value='" & Session("LASTNAME") &"'><input type='hidden' name='CMNTitle0' id='CMNTitle0' value='" & Session("TITLE") &"'><input type='hidden' name='CMNEMail0' id='CMNEMail0' value='" & Session("EMAIL") &"'><input type='hidden' name='CMNFrequency0' id='CMNFrequency0' value='1'>"

tblRow.Cells.Add(tblCell)

EndIf

dvConsManage.Dispose()

If dsConsManage.Tables("Notifications").Rows.Count = 0Then

CreateDefaultConManageLocNotification()

EndIf

ForEach drRowIn dsConsManage.Tables("Notifications").Rows

If drRow("UserManageable") =TrueThen

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fDeleteRecip(" & Chr(34) & drRow("NotificationID") & Chr(34) &");'><IMG Src='images\red_x_trans.gif' border='0' height='10px' width='10px'></a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text ="<a href='javascript:fLoadRecipDialog(" & Chr(34) & drRow("NotificationID") & Chr(34) &");'>" & drRow("FirstName") &" " & drRow("LastName") &"</a>"

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = m_aryFrequencies(drRow("Frequency")) &"<input type='hidden' name='CMNFirstName" & drRow("NotificationID") &"' id='CMNFirstName" & drRow("NotificationID") &"' value='" & drRow("FirstName") &"'><input type='hidden' name='CMNLastName" & drRow("NotificationID") &"' id='CMNLastName" & drRow("NotificationID") &"' value='" & drRow("LastName") &"'><input type='hidden' name='CMNTitle" & drRow("NotificationID") &"' id='CMNTitle" & drRow("NotificationID") &"' value='" & drRow("Title") &"'><input type='hidden' name='CMNEMail" & drRow("NotificationID") &"' id='CMNEMail" & drRow("NotificationID") &"' value='" & drRow("EMail") &"'><input type='hidden' name='CMNFrequency" & drRow("NotificationID") &"' id='CMNFrequency" & drRow("NotificationID") &"' value='" & drRow("Frequency") &"'>"

tblRow.Cells.Add(tblCell)

EndIf

Next

tblRow =New TableRow

tblNotifications.Rows.Add(tblRow)

tblCell =New TableCell

tblCell.Text = hdnAction.Value

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = Now.ToString

tblRow.Cells.Add(tblCell)

tblCell =New TableCell

tblCell.Text = hdnID.Value

tblRow.Cells.Add(tblCell)

dsConsManage.Dispose()

daConsManage.Dispose()

cnRetailCommerce.Close()

cnRetailCommerce.Dispose()

hdnID.Value =""

hdnAction.Value =""

EndSub

PrivateSub CreateDefaultConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

Dim parmUserManageableAsNew SqlParameter("@.P_USERMANAGEABLE", Data.SqlDbType.Int)

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value ="John"

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value ="Romeo"

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value ="AWT Consignment Inventory Manager"

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value ="JRomeo@.harsco.com"

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = 1

parmUserManageable.Direction = Data.ParameterDirection.Input

parmUserManageable.Value = 0

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGECREATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.Parameters.Add(parmUserManageable)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub CreateConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

Dim parmUserManageableAsNew SqlParameter("@.P_USERMANAGEABLE", Data.SqlDbType.Int)

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value = txtRecipFirstName.Text

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value = txtRecipLastName.Text

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value = txtRecipTitle.Text

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value = txtRecipEMail.Text

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = drpFrequency.SelectedValue

parmUserManageable.Direction = Data.ParameterDirection.Input

parmUserManageable.Value = 1

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGECREATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.Parameters.Add(parmUserManageable)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub DeleteConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmNotificationIDAsNew SqlParameter("@.P_NOTIFICATIONID", Data.SqlDbType.Int)

parmNotificationID.Direction = Data.ParameterDirection.Input

parmNotificationID.Value = hdnID.Value

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGEDELETELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmNotificationID)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

PrivateSub UpdateConManageLocNotification()

Dim cmdUpdateAsNew SqlCommand

Dim parmNotificationIDAsNew SqlParameter("@.P_NOTIFICATIONID", Data.SqlDbType.Int)

Dim parmCLocationAsNew SqlParameter("@.P_CLOCATION", Data.SqlDbType.VarChar, 50)

Dim parmFirstNameAsNew SqlParameter("@.P_FIRSTNAME", Data.SqlDbType.VarChar, 20)

Dim parmLastNameAsNew SqlParameter("@.P_LASTNAME", Data.SqlDbType.VarChar, 50)

Dim parmTitleAsNew SqlParameter("@.P_TITLE", Data.SqlDbType.VarChar, 50)

Dim parmEMailAsNew SqlParameter("@.P_EMAIL", Data.SqlDbType.VarChar, 255)

Dim parmFrequencyAsNew SqlParameter("@.P_FREQUENCY", Data.SqlDbType.Int)

parmNotificationID.Direction = Data.ParameterDirection.Input

parmNotificationID.Value = hdnNotificationID.Value

parmCLocation.Direction = Data.ParameterDirection.Input

parmCLocation.Value = Session("CMLocation")

parmFirstName.Direction = Data.ParameterDirection.Input

parmFirstName.Value = txtRecipFirstName.Text

parmLastName.Direction = Data.ParameterDirection.Input

parmLastName.Value = txtRecipLastName.Text

parmTitle.Direction = Data.ParameterDirection.Input

parmTitle.Value = txtRecipTitle.Text

parmEMail.Direction = Data.ParameterDirection.Input

parmEMail.Value = txtRecipEMail.Text

parmFrequency.Direction = Data.ParameterDirection.Input

parmFrequency.Value = drpFrequency.SelectedValue

cmdUpdate.Connection = cnRetailCommerce

cmdUpdate.CommandType = Data.CommandType.StoredProcedure

cmdUpdate.CommandText ="USP_CONSMANAGEUPDATELOCNOTIFICATIONS"

cmdUpdate.Parameters.Add(parmNotificationID)

cmdUpdate.Parameters.Add(parmCLocation)

cmdUpdate.Parameters.Add(parmFirstName)

cmdUpdate.Parameters.Add(parmLastName)

cmdUpdate.Parameters.Add(parmTitle)

cmdUpdate.Parameters.Add(parmEMail)

cmdUpdate.Parameters.Add(parmFrequency)

cmdUpdate.ExecuteNonQuery()

cmdUpdate.Dispose()

EndSub

EndClass


Bump - I have a huge need to get this working. can someone please help?

Modal Popup not posting TextBox fields

I have a strange situation in which I am using a Model Popup Control with an embedded GridView containg TextBox controls in a column. I can DataBind the GridView in the codebehind and the TextBox controls are properly populated. However, when the pack posts back, the TextBox Controls always have an empty string for the Text property? This also occurs if I replace the GridView with a Repeater or any other list control.

Other controls, like labels, have there Text property available.

craig

You might want to look at this post:

http://forums.asp.net/thread/1328079.aspx

Look at the second page, at the last post with the JavaScript.

They have done some nice work with the modal regarding this issue I think.

There was also a workaround using the SubmitButtonBehavor = false;

Dont know if this will help you, but I thought I would give it a shot

Good luck

-Shane

Wednesday, March 21, 2012

ModalPopup -> UserControl -> fire event ?

Hello !

Because I made different scenarios with modalpopups, I have this situation :

1) I create ModalPopup dynamically

2) Load dynamically a usercontrol into a ModalPopup (and set usercontrol ID)

3). UserControl has buttons OK,Cancel and btnFireClick with click event on a server

Everything is fine, except that when I click btnFireClick the click event didnt fire...

If I set the same buttons into modalpopup but not like usercontrol - event is executed

If I load the usercontrol in the page (not in modalpopup) - event is executed

But if I load usercontrol into modalpopup - event didnt execute

Where is the problem ?

I use Microsoft ASP.NET 2.0 AJAX Extensions

Please try your scenario with the recently available61121 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, simple, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

2) Load dynamically a usercontrol into a ModalPopup (and set usercontrol ID)

Your user control is a server side control which renders a bunch of html controls at the client side, it is not like a Panel server control which renders a div at the client side.


The second thing you may want to look at is, if you load the user control dynamically, you will have to load the user control every postback within OnInit or OnLoad and give it the same name since you the first time you load the user control dynamically. Otherwise, the event won't fire and the control does not even exist.

modalpopup & user control question

Hi all,

I hope all of you are doing well!Big Smile I have an interesting situation that I wanted to get some input on.

I have a ascx usercontrol that contains about a dozen textbox and dropdown controls inside an updatepanel. It also has a few buttons that fire server side events, all contained and handled in the code behind page for the usercontrol. This usercontrol resides on a host aspx page inside another updatepanel control. Everything works fine thus far.

Now, what I would like to do is dynamically popup the usercontrol inside a modalpopup when the user clicks on a button on the host aspx page. The user would then enter the data for the dozen or so fields on the popped up usercontrol, hit update, which would invoke the server side code inside the code behind of the usercontrol and finally close the modalpopup.

Is this possible? Some insight on how I can do this would be great. Some links to code samples would be even more awesome.

Thanks so much!

Hi,

Here is a sample made according to your requirements:

1. UserControl

<%@. Control Language="C#" ClassName="WebUserControl" %><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); success = true; } // this variable is used to determine if the modal popup should close public bool success = false;</script><asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> <br /> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </ContentTemplate></asp:UpdatePanel> 

2. Page

<%@. Page Language="C#" %><%@. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { this.PreRender += new EventHandler(default_aspx_PreRender); } void default_aspx_PreRender(object sender, EventArgs e) { if (WebUserControl1.success) UpdatePanel1.Update(); }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate>    <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> <uc1:WebUserControl ID="WebUserControl1" runat="server" /> </asp:Panel> <asp:Button ID="Button1" runat="server" Text="Show" /> <ajaxToolkit:ModalPopupExtender PopupControlID="Panel1" ID="ModalPopupExtender1" runat="server" TargetControlID="Button1"> </ajaxToolkit:ModalPopupExtender> </ContentTemplate> </asp:UpdatePanel>   </form></body></html>

Hope this helps.


Thanks. This worked perfectly!!