Drop it. Note how to dynamically load a user control (ascx)
Source: Internet
Author: User
Dynamic | load | Control NOTE: This method is my colleague Li Qiang original
Step one: Drag the ascx control into the design window and then into HTML mode, reserving the definition
If you need more than one ascx, please drag them all in.
But remove the corresponding content. (because we need to load dynamically)
Where you need to fill in the control, put a container, such as TD, and set on the server side to run
Such as
<TD id= "Tdpan" runat=server></td>
2: Dynamic invocation
UserControl MyUserControl = (UserControl) LoadControl (".. /includes/pagenavigater.ascx ");
Type Myusertype = MyUserControl. GetType ();
Here is the assignment to ascx
PropertyInfo myuserinfo1 = Myusertype. GetProperty ("Relateddatagrid"),//). GetProperty ("Relateddatagrid");
Myuserinfo1. SetValue (myusercontrol,gridhwcy, NULL);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.