473,511 Members | 14,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

usercontrol and modalPopupExtender

I have a set of controls and logic that must be invoked from several pages
within a web application as a popup dialog, so I intend to use a userControl
contained in a panel extended with the modalPopupExtender to get this
behavior. I want to deal with showing and hiding the popup in server-side
code, so I've set the TargetControlID to a hidden (style=display:none;)
button and not set the OkButton or CancelButton. The userControl has several
events designed to signal the disposition of the user's interaction with the
control. The problem that I am having is that whenever an action is taken on
the control that causes an interaction with the server side code, the popup
is closed and my events are never fired in the containing page. Has anyone
successfully used the modalPopupExtender in this manner?
Aug 14 '07 #1
1 18800
JB
Just had the same issue as you Kyle. I had a user control that creates
new customer accounts. On my asp.net page I had a ModalPopupExtender
with a link button "Add Account". Clicking Add Account launches the
modal popup to the screen so the user can create a new account.

Problems I encountered were:
1. How to close of the modal popup when user clicked the cancel button
(The cancel button is part of the CreateAccount usercontrol)
2. How to close of the modal popup when the user clicked the OK
button. (The OK button is also part of the CreateAccount usercontrol).

Note: I added an update panel inside the panel control (that hosts my
usercontrol) in my asp.net page. This was to have ajax (partial)
postbacks when the user interacted with the modal dialog.

I added two public events to my usercontrol ItemCreated and
ItemCancelled. These events were raised when the cancel and OK buttons
get clicked. I then handle these events in the asp.net page and call
the Hide() method on the ModalPopupExtender to close the modal popup.
// Events in my CreateAccount user control

public event EventHandler ItemCreated;
public event EventHandler ItemCancelled;

protected void btnCancel_Click(object sender, EventArgs e)
{
lblStatus.Text = "Cancelling...";

if (ItemCancelled != null)
{
this.ItemCancelled(this, new EventArgs());
}
}

protected void btnSubmit_Click(object sender, EventArgs e)
{
lblStatus.Text = "Creating...";

if (ItemCreated != null)
{
this.ItemCreated(this, new EventArgs());
}
}

// MyAspxPage.aspx

<asp:LinkButton ID="LinkButton1" runat="server" Text="add account"></
asp:LinkButton>

<asp:Panel ID="Panel1" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<uc1:CreateAccount ID="CreateAccount "
runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1"
runat="server"
PopupDragHandleControlID="Panel1"
TargetControlID="LinkButton1"
PopupControlID="Panel1"
BackgroundCssClass="modalBackground"
DropShadow="false" />

// MyAspxPage.cs

protected void Page_Load(object sender, EventArgs e)
{
this.CreateAccount1.ItemCancelled += new
EventHandler(CreateAccount1_ItemCancelled);
this.CreateAccount1.ItemCreated += new
EventHandler(CreateAccount1_ItemCreated);

}

void CreateAccount1_ItemCreated(object sender, EventArgs e)
{
this.ModalPopupExtender1.Hide();
}

void CreateAccount1_ItemCancelled(object sender, EventArgs e)
{
this.ModalPopupExtender1.Hide();
}
Cheers,
John

Kyle M. Burns wrote:
I have a set of controls and logic that must be invoked from several pages
within a web application as a popup dialog, so I intend to use a userControl
contained in a panel extended with the modalPopupExtender to get this
behavior. I want to deal with showing and hiding the popup in server-side
code, so I've set the TargetControlID to a hidden (style=display:none;)
button and not set the OkButton or CancelButton. The userControl has several
events designed to signal the disposition of the user's interaction with the
control. The problem that I am having is that whenever an action is taken on
the control that causes an interaction with the server side code, the popup
is closed and my events are never fired in the containing page. Has anyone
successfully used the modalPopupExtender in this manner?
Sep 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8011
by: suzi167 | last post by:
Hello Everyone, I am having the following issue. I have an AJAX enabled Web Application in C#. I am using a Master Page and then I have a Default.aspx page which is based on the Master page....
0
3192
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I have a web form, and I want to use ModalPopupExtender from Ajax Toolkit. I am using IE 7.0 as browser, VS 2005 and Ajax and Ajax Tool Kit installed. Windows XP Pro. Now I have a...
1
4709
by: Victor | last post by:
Hi guys i have a strange problem about my modalpopupextender. In my page, i put a gridview inside a updatepanel with paging enabled. also i put a modalpopupextender in another updatepanel to do...
0
3939
by: SD | last post by:
Hi, I have to use the ModalPopupExtender prgrammatically.. But the next sample doesn't work: ************************** protected Button bt; protected Button bc; protected Button b; protected...
0
2023
by: ujjc001 | last post by:
Ok, I have a modalpopupextender (MPE) with a usercontrol (UC) inside it. The UC has a multiview with 3 views and a button on each to procede to the next and finally close the popup. The problem...
0
3101
by: vincent90152900 | last post by:
In a web page,” Default.aspx”, I have two different WebUserControl,” WebUserControl1_1”, and “WebUserControl2_1” and a ModalPopupExtender,” ModalPopupExtender1” and a Button,” Button1” and a Panel,”...
0
1904
by: mohaaron | last post by:
Hello all, I have been using the ModalPopupExtender as a way of catching errors and displaying them to users. This includes business rule violations that I catch. This all works fine as long as...
2
3835
by: Peter | last post by:
I am trying to use ASP.NET Ajax Control Toolkit ModalPopupExtender which works fine, but what I am trying to do is: 1) User Clicks on the button: 2) Function on the server will check for a...
0
1922
by: uicouic | last post by:
Hi all. I am having trouble getting a ModalPopupExtender to display with the corresponding data. This will be triggered by clicking on a "Details" button in a gridview. Eg. by clicking on Row1...
0
7237
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7417
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.