F
Francois Beauchemin
Hi, I try to create a custom Webcontrol who load others controls from a
string... My code seems to works well at runtime, but in design-time I
have a NullReferenceException when I try to parse a control with
ParseControl. ( see code bellow )
It is a bug of ParseControl? Or maybe ParseControl is not intended to be
use at design-time ( if so... not documented! ) ...
Anyone have an idea ?
Francois Beauchemin
Note : I'm using .NET Frameworks 1.0 ...
Here is my class :
Public Class TemplateTest
Inherits TemplateControl
Private ctl As Control
Protected Overrides Sub CreateChildControls()
MyBase.CreateChildControls()
Controls.Add(ctl)
End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
ctl = ParseControl("<asp:label id=""Label1""
runat=""server"">Test!</asp:label>")
MyBase.OnInit(e)
End Sub
End Class
Here is the stactTrace. ( Sorry for the french message! )
"System.NullReferenceException: La référence d'objet n'est pas définie à
une instance d'un objet.
at System.Web.UI.BaseParser.MapPath(String path, Boolean
allowCrossAppMapping)
at System.Web.UI.BaseParser.MapPath(String path)
at System.Web.UI.TemplateParser.ParseTemplateInternal(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateParser.ParseTemplate(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateParser.ParseControl(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateControl.ParseControl(String content)
at MyNameSpace.TemplateTest.OnInit(EventArgs e) in
C:\test\TemplateTest.vb:line 21"
string... My code seems to works well at runtime, but in design-time I
have a NullReferenceException when I try to parse a control with
ParseControl. ( see code bellow )
It is a bug of ParseControl? Or maybe ParseControl is not intended to be
use at design-time ( if so... not documented! ) ...
Anyone have an idea ?
Francois Beauchemin
Note : I'm using .NET Frameworks 1.0 ...
Here is my class :
Public Class TemplateTest
Inherits TemplateControl
Private ctl As Control
Protected Overrides Sub CreateChildControls()
MyBase.CreateChildControls()
Controls.Add(ctl)
End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
ctl = ParseControl("<asp:label id=""Label1""
runat=""server"">Test!</asp:label>")
MyBase.OnInit(e)
End Sub
End Class
Here is the stactTrace. ( Sorry for the french message! )
"System.NullReferenceException: La référence d'objet n'est pas définie à
une instance d'un objet.
at System.Web.UI.BaseParser.MapPath(String path, Boolean
allowCrossAppMapping)
at System.Web.UI.BaseParser.MapPath(String path)
at System.Web.UI.TemplateParser.ParseTemplateInternal(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateParser.ParseTemplate(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateParser.ParseControl(String content,
HttpContext context, String baseVirtualDir)
at System.Web.UI.TemplateControl.ParseControl(String content)
at MyNameSpace.TemplateTest.OnInit(EventArgs e) in
C:\test\TemplateTest.vb:line 21"