Web user control inside update panel replace with another web user control


 Hi there.
I have a page with a menu. an and then the content.
My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control.
In normal language. Is there a way that i can load one web user control into antoher and then disposose the original?
Thanks in advance
0
KeysMan
6/6/2006 6:45:39 PM
📁 asp.net.ajax-discussion
📃 13973 articles.
⭐ 1 followers.

💬 5 Replies
👁️‍🗨️ 2100 Views



hello.
well, what you can do is get a reference to the placeholder where your user control is being loaded. then you can remove your 1st user control and add the new one.

-- 
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
0
Luis
6/6/2006 9:42:07 PM
Thanks a lot. But i can't seem to figure out how to get it to work inside the update panel. Could you plees give a code example?

My best regards
0
KeysMan
6/9/2006 4:13:08 PM

hello.
not suer if this is your scenario, but it should point you in the right direction (as allways, there are other ways of doing this):
user1.ascx
<%@ Control Language="C#" ClassName="user1" %>
<%@ Reference VirtualPath="user2.ascx" %>
<script runat="server">
    void handle(object sender, EventArgs args)
    {
        Page page = this.Page;
        Control ctl = page.FindControl("holder");
        ctl.Controls.Add(this.LoadControl("user2.ascx"));
        ctl.Controls.Remove(this);
    }
</script>
user control 1
<asp:Button runat="server" ID="bt" Text="Change to 2" OnClick="handle" />
user2.ascx
<%@ Control Language="C#" ClassName="user2" %>
<script runat="server">
</script>
Control 2
userpage.aspx
<%@ Page Language="C#" %>
<%@ Register Src="~/user1.ascx" TagName="user" TagPrefix="pr" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title> <meta name="viewport" content="width=device-width">
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <atlas:ScriptManager runat="server" ID="manager" EnablePartialRendering="true" />
        <atlas:UpdatePanel runat="server" id="panel">
            <ContentTemplate>
                <asp:Panel runat="server" ID="holder">
                    <pr:user runat="server" id="usr" />
                </asp:Panel>
            </ContentTemplate>
        </atlas:UpdatePanel>
    </div>
    </form>
</body>
</html>

-- 
Regards,
Luis Abreu
email: labreu_at_gmail.com
EN blog:http://msmvps.com/blogs/luisabreu
0
Luis
6/10/2006 10:21:04 AM
Thanks a lot.

0
KeysMan
6/10/2006 11:26:53 AM

Hi,
 I have a similar kind of issue. My user control has a dropdownlist and list box based on the property DisplayControl set , either dropdown list or list box will be displayed in the calling page.
I am placing this user control inside a gridview - Edit item template and Gridview is placed inside an updatePanel. This way control is working fine, but the update becomes really slow (around 5min).
Any suggestion to solve is appreciated.
 Thanks and Regards

Prabhavathi
0
prabavathinew
8/31/2007 11:54:49 AM
Reply: