Hello Walter,
So why I get this exception trying to initialize a SkinID:
(this has been solved by initializing SkinID in PreInit for dynamic
controls)
ProcessUnhandledException enter GetLastError:
System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.InvalidOperationException: The 'SkinId' property can only be set in
or before the Page_PreInit event for static controls. For dynamic controls,
set the property before adding it to the Controls collection.
at System.Web.UI.Control.set_SkinID(String value)
at System.Web.UI.WebControls.WebControl.set_SkinID(St ring value)
at AddonNice.UI.WebControls.PortalModuleControl.OnIni t(EventArgs e)
at Ax.WTPageModules.PortalsAdmin.Portals.OnInit(Event Args e)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.InitRecursive(Control namingContainer)
at System.Web.UI.Control.AddedControl(Control control, Int32 index)
at System.Web.UI.ControlCollection.Add(Control child)
at System.Web.UI.WebControls.Table.RowControlCollecti on.Add(Control
child)
at Ax.UI.WebControls.DesktopPanes0.CreateControlHiera rchy()
at Ax.UI.WebControls.DesktopPanes0.CreateChildControl s()
at System.Web.UI.Control.EnsureChildControls()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.desktopdefault_aspx.ProcessRequest(HttpContext context)
at
System.Web.HttpApplication.CallHandlerExecutionSte p.System.Web.HttpApplication.IExecutionStep.Execut e()
at System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)
"Walter Wang [MSFT]" <wa****@online.microsoft.coma écrit dans le message
de news:
tM**************@TK2MSFTNGHUB02.phx.gbl...
Hi CS,
It seems I may have misunderstood something regarding the PreInit event.
It's actually only Page.Theme property can be set in PreInit. Setting
Control.SkinID should be fine in Page_Load or during DataBinding:
<%@ Page Language="C#" Theme="Theme1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
TextBox txt1 = new TextBox();
txt1.Text = "Page_Load";
txt1.SkinID = "BlueTheme";
form1.Controls.Add(txt1);
this.DataBinding += new EventHandler(default2_aspx_DataBinding);
this.DataBind();
}
void default2_aspx_DataBinding(object sender, EventArgs e)
{
TextBox txt1 = new TextBox();
txt1.Text = "DataBinding";
txt1.SkinID = "BlueTheme";
form1.Controls.Add(txt1);
}
</script>
I'm sorry if I may have caused some confusion in my previous replies.
Regards,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.