|
-
Jan 18th, 2007, 06:57 AM
#1
Thread Starter
PowerPoster
[2005] Page with multiple user controls..
Hey guys, I'm trying to modularise my page abit by doing the following,
Code:
<%@ Register Src="suppliers/viewsuppliers.ascx" TagName="viewsuppliers" TagPrefix="supp" %>
<%@ Register Src="suppliers/newsupplier.ascx" TagName="newsupplierform" TagPrefix="supp" %>
<%@ Register Src="suppliers/deletesupplier.ascx" TagName="deletesupplierform" TagPrefix="supp" %>
//And below
<div id="NewSupplierContainer" runat="server">
<supp:newsupplierform ID="NewSupplier" runat="server" />
</div>
<div id="DeleteSupplierContainer" runat="server">
<supp:deletesupplierform id="DeleteSupplier" runat="server" />
</div>
<div id="ViewSupplierContainer" runat="server">
<supp:viewsuppliers ID="ViewSupplier" runat="server" />
</div>
And then on Page_Load, I check the arguments,
Code:
protected void Page_Load(object sender, EventArgs e)
{
DeleteSupplierContainer.Visible = false;
NewSupplierContainer.Visible = false;
if (Request.QueryString["action"] != null)
{
ViewSupplierContainer.Visible = false;
switch (Request.QueryString["action"].ToUpper())
{
case "NEW":
NewSupplierContainer.Visible = true;
break;
case "DELETE":
DeleteSupplierContainer.Visible = true;
break;
}
}
}
However, my faith in the fact that code that is set to Invisible is not run has been proven wrong. 
Anyone have any suggestions on how I could make it so that only one of the 3 pages get loaded at a time?
-
Jan 18th, 2007, 11:21 AM
#2
Re: [2005] Page with multiple user controls..
Instead of having the controls always on the page but set to visible or not. Just add the control you need to add at runtime.
Add a placeholder to your page and add your controls to that.
Code:
Control c;
switch (Request.QueryString["action"].ToUpper())
{
case "NEW":
c = LoadControl("newsupplierform.ascx");
c.ID = "NewSupplier";
break;
case "DELETE":
c = LoadControl("deletesupplierform .ascx");
c.ID = "DeleteSupplier";
break;
}
this.placeholder.Controls.Add(c);
-
Jan 18th, 2007, 04:59 PM
#3
Thread Starter
PowerPoster
Re: [2005] Page with multiple user controls..
Awesome, thanks FishCake, that did the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|