Server Form Object not set in Page_Load event (at least against documentation)

F

Frank L

Hi,
I found something that is literally bugging me, maybe I am doing
someting wrong, but it looks crap.

There is a hidden field on a Control (the form comes from the Parent
page:

<input type="hidden" runat="server" id="structure2Publish"
NAME="structure2Publish"/>
...
<asp:placeHolder Runat="server" ID="SomeBackput"></asp:placeHolder>

It's counterpart in the code-behind:

protected HtmlInputHidden structure2Publish;

Then I've got some JScript that is called after clicking a link:

function startPublishing(title, structure) {
var msg = 'bla';
var answer = window.confirm(msg + "\n" + title);
if (answer)
{
document.getElementById('<%= structure2Publish.ClientID
%>').value =
structure;
//__doPostBack('_ctl6$structure2Publish','');
document.forms.item(0).submit();
}
}

In the Page_Load I have the following code:

SomeBackput.Controls.Add( new System.Web.UI.LiteralControl("Should be
visible:"
+ structure2Publish.Value + "<br/>"));
foreach (string s in Request.Form)
{
SomeBackput.Controls.Add( new System.Web.UI.LiteralControl(s + ": "
+
Request.Form + "<br/>"));
}

And in the Pre_Render I've got the following:

SomeBackput.Controls.Add(new System.Web.UI.LiteralControl("and now?" +
structure2Publish.Value));


The relevant output on the page is as follows:

Should be visible:
__EVENTTARGET:
__EVENTARGUMENT:
__VIEWSTATE: dDwxMDY3NDc0NzY7dDw7b [snip]...
_ctl7:query:
_ctl6:structure2Publish: 2139
_ctl9:drpDwnPubs:
and now?2139


Hm...I haven't checked right now, but I am sure the asp Controls don't
show this behaviour, their value is correctly initialised in the
Page_Load. I know the hidden field is not an asp control. But at the
end of the day the docs say about Page_Load:

....You can acess view state information and form POST data from this
event...

It's kinda correct, but why doesn't my field become correctly set
until AFTER Page_Load? Is this a bug or am I missing something?

This is ASP.NET 1.1

Over and out

F Quednau
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top