Design-time problem with ParseControl ...

  • Thread starter Francois Beauchemin
  • Start date
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"
 
V

Victor Garcia Aprea [MVP]

Hi Francois,

Its not intended to be used at design-time.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top