forms - SiteFinity 4.0: Trouble Accessing Postback Data in Custom User Control -
i'm trying highly customized hand built form sitefinity 4.0 , problem no matter can't access form's postback data in code behind. form user control , i've added in way described here: http://www.sitefinity.com/40/help/developer-manual/controls-adding-a-new-control.html
after struggling several hours, created basic test form , i'm still not able access postback data. i've tried adding enableviewstate="true" on place form data still empty on postback. exact same user control runs , posts data outside of sitefinity. tried other methods of accessing postback data , discovered request.form contain data need. i'd still love access form elements in usual way though, don't have request.form every control on page , loop way, seems hokey.
here's code basic form:
"basicusercontrol.ascx"
<%@ control language="c#" autoeventwireup="true" codebehind="basicusercontrol.ascx.cs" inherits="sitefinitywebapp.usercontrols.assessments.basicusercontrol" enableviewstate="true" %> <div id="assessmentdiv" runat="server"> <asp:textbox id="textbox1" runat="server" clientidmode="static" enableviewstate="true"></asp:textbox> <asp:literal id="literal1" runat="server" clientidmode="static" enableviewstate="true"></asp:literal> <asp:button id="button1" runat="server" text="button" /> </div>
"basicusercontrol.ascx.cs" code behind
using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace sitefinitywebapp.usercontrols.assessments { public partial class basicusercontrol : system.web.ui.usercontrol { protected void page_load(object sender, eventargs e) { if (ispostback) { literal1.text = textbox1.text; } } } }
again, if add control via method described @ link above, able create sitefinity 4.0 cms page, drag control onto it, run page, step code behind using debugger, yet when vs2010 reaches line below there no form data being posted:
literal1.text = textbox1.text;
fyi: reason why there no form tag in usercontrol.ascx code above because error when running form thru sitefinity 1 server-side form tag can exist on .net page (sitefinity injects it's own form tag).
thanks in advance help!
ben
never mind - figured out. reason, data isn't available @ page_load stage of .net page lifecycle in sitefinity form submission (at least not via custom user control). if wait until page_prerender stage retrieve data form on page, it's there.
my current prevailing theory sitefinity 4.0 grabs postback data when form submits , hasn't finished monkeying around @ page_load stage, have wait until page_prerender stage before sitefinity has injected data page cycle.
Comments
Post a Comment