Insus. NET believes that many netizens will dynamically Add User Controls. For example, the blog post written before Insus. NET:
Http://www.cnblogs.com/insus/archive/2012/04/16/2451085.html
Http://www.cnblogs.com/insus/articles/2023678.html
Or a blog post related to a user control: http://www.cnblogs.com/insus/category/341697.html
However, Insus. NET wants to use the RenderControl method of the control to dynamically load the user control.
Create a user control in the site, write some files and pull an image.
InsusUserControl. ascx
On the site, create a. aspx webpage and pull a control:
In. aspx. cs, write a private method. The Render user control is a string with a parameter that is used to input the user control file name, including its directory.
In the. aspx. cs Page_Load event, you can obtain the string after the user control Render and assign it to the Literal control.
Page_Load (= RenderUserControlToString (
To solve the exceptions that occur when the control. RenderControl () method is executed, you also need to write two methods in override on the webpage:
{View Code
After writing, run: