Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > usercontrol and modalPopupExtender

Reply
Thread Tools

usercontrol and modalPopupExtender

 
 
=?Utf-8?B?S3lsZSBNLiBCdXJucw==?=
Guest
Posts: n/a
 
      08-14-2007
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?
 
Reply With Quote
 
 
 
 
JB
Guest
Posts: n/a
 
      09-24-2007
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>

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

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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ModalPopupExtender and opacity IE kendalljones99@yahoo.com ASP .Net 0 05-28-2008 06:30 PM
ModalPopupExtender and Event Melina ASP .Net 0 12-09-2007 01:32 PM
modalpopupextender containing usercontrol which does its own postbacks ujjc001 ASP .Net 0 07-25-2007 08:51 PM
ModalPopupExtender and DOCTYPE problem =?Utf-8?B?SGFyZHkgV2FuZw==?= ASP .Net 0 04-23-2007 09:46 PM
want to have <cc:UserControl>some text and tags</cc:UserControl>... How? ThunderMusic ASP .Net 4 12-21-2005 11:59 AM



Advertisments