Look below this typical background (rough):
To tell you the truth, I am tired of using the. aspx file, such as "Friendship link" This module, there will be "Add Friendship link" "Modify Friendship Connection" "Friendship Connection list", simple words, you can "add" "modify" to synthesize a file. Each time you create an. aspx file. My idea now is to use the "user Control + configuration file" to implement, although the number of files may not be much less. But in the programming to a certain extent, I think we will have the same idea.
The first thing to involve is the dynamic addition of the user control, which can be dynamically loaded according to the parameters, as follows:
Copy Code code as follows:
protected control control;
protected void Page_Load (object sender, EventArgs e)
{
by Ahuinan 2009-4-18
int id = Convert.ToInt32 (request.querystring["id"]);
Switch (ID)
{
Case 0://do not load user controls
Response.Write ("You did not load any controls");
Break
Case 1://Load User control
Control = Page.LoadControl ("~/login.ascx");
Control.id = "uc1";//This is named in order to get the value of the inside control.
PlaceHolder1. Controls.Add (Control);
Break
Default
Break
}
}
Instead, you need only one. aspx file, and there is a user control in the file, and the code is as follows:
Copy Code code as follows:
<asp:placeholder runat= "Server" id= "PlaceHolder1" ></asp:placeholder>
If you have a textbox with the id "tbxusername" in this "user control", in the. aspx file, to get this value, the code is as follows:
Copy Code code as follows:
((TextBox) placeholder1. FindControl ("uc1"). FindControl ("Tbxusername")). Text
Here is simple to say my idea, to cooperate with the http://www.jb51.net/article/17829.htm I said before this article implements a class that inherits from page, writing code that dynamically loads the user control. You need to work with a configuration file so that the left menu and dynamically loaded controls can be uniformly handled in the configuration file. The idea is very clear, but the writing is a bit messy, hope to have this thinking friend and I exchange, recently and a few friends chatted, but did not have such an idea.