problem with parsecontrol
hi i have a problem with the parsecon开发者_Go百科trol() method
Control c = this.ParseControl("<uc1:GroupListControl NickName='HARD' GroupName='STUFF' runat='server' ID='Abekat' />"); <-- error Unknown server tag 'uc1:GroupListControl'.
Control c3 = ParseControl("<asp:button id='Button3' text='Btn3' runat='server' />"); <-- this works just fine
why do i get the error from my own webusercontrol ? i have registered it in the html page like this
<%@ Register src="~/webcontrols/GroupListControl.ascx" tagname="GroupListControl" tagprefix="uc1" %>
Greetings Entvex
You should try to include "Register" directive into you ParseControl statement, like the following:
Control c =
this.ParseControl("<%@ Register src=\"GroupListControl.ascx\" tagname=\"GroupListControl\" tagprefix=\"uc1\" %> <uc1:GroupListControl ID=\"GroupListControl1\" runat=\"server\" />");
For additional information see this article.
Also maybe Page.LoadControl method will be useful for you.
精彩评论