Rank: Newbie Groups: Member
Joined: 9/21/2008 Posts: 4
|
is it possible to do this dynamically.
E.g.
Dim dp As New EO.Web.DatePicker Dim sb As New StringBuilder() Dim sw As New IO.StringWriter(sb) Dim w As New HtmlTextWriter(sw)
dp.ID = "TEST" dp.RenderControl(w) 'CRASHES HERE
Response.Write(sb.ToString())
crashes with...
Server Error in '/TestFirewall' Application.
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 21: dp.ID = "TEST" Line 22: Line 23: dp.RenderControl(w) Line 24: 'form.Controls.Add() Line 25: 'page.Form = form
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.] EO.Web.Internal.b5.e() +203 EO.Web.Internal.b5.n() +4 EO.Web.Calendar.c(EventArgs A_0) +48 EO.Web.WebControlBase.p() +183 EO.Web.WebControl.l(HtmlTextWriter A_0) +24 EO.Web.Calendar.a(HtmlTextWriter A_0) +32 EO.Web.WebControlBase.n(HtmlTextWriter A_0) +61 EO.Web.WebControlBase.b(HtmlTextWriter A_0) +138 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +121 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +22 _Default.Page_Load(Object sender, EventArgs e) in C:\Dev\Misc\TestFirewall\Default.aspx.vb:23 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
DatePicker requires a Page, a server form and full life cycle to work properly. This is necessary for the DatePicker because it may not render all output at one place. For example, while it renders HTML inside the document body, it also renders some style block into the page header. So if you wish to render the DatePicker, you will need to place it in the page. You can dynamically set its Visible to true or false to control whether you the DatePicker is shown or not.
Thanks!
|