471,595 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

Request.Form with Masterpage

Hello,

How do you use Request.Form["HiddenField"] when the first page is using a
MasterPage?

Thanks, sck10
Nov 23 '06 #1
6 11443
Hello Steve,

Do you mean in the original page, the hidden fields are put on MasterPage's
content? If so, this does make the identification of the hidden
fields(form items) in target page abit difficult. Becaue for controls put
in Master page, its name and id will be mangled. For example, the following
html control in master page

=========
<input id="hidden1" name="hidden1" runat="server" type="hidden"
value="hidden1 value" />
<input id="hidden2" name="hidden2" runat="server" type="hidden"
value="hidden2 value" />
===========

will be rendered as below finally:

<input name="ctl00$hidden1" type="hidden" id="ctl00_hidden1"
value="hidden1 value" />
<input name="ctl00$hidden2" type="hidden" id="ctl00_hidden2"
value="hidden2 value" />

Thus, on the target page, you can not directly use the original
hiddenfield's name to quey the Request.Form collection. One flexible means
is to query the Request.Form collection and find the one that contains the
hiddenfield's unmangled name. e.g.

========in target page===============

protected void Page_Load(object sender, EventArgs e)
{
foreach (string key in Request.Form.Keys)
{
if(key.Contains("hidden1"))
Response.Write("<br/>" + key + ": " + Request.Form[key]);
}
}
==============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Nov 23 '06 #2
Hi,

Steven Cheng[MSFT] wrote:
Becaue for controls put in Master page, its name and id will be mangled.
.... which you can work around by using the .ClientID-property.

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 23 '06 #3
Hi Olaf,

thanks for your input.

I think what you mentioned should be "Control.UniqueID" :)

http://msdn2.microsoft.com/en-us/lib....uniqueid(VS.8
0).aspx

BTW, the problem here is that he is cross post to a remote page on
different server, this "UniqueID" is not workable.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 23 '06 #4
Thanks Walter, I will try your suggestion.

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:gt**************@TK2MSFTNGXA01.phx.gbl...
Hello Steve,

Do you mean in the original page, the hidden fields are put on
MasterPage's
content? If so, this does make the identification of the hidden
fields(form items) in target page abit difficult. Becaue for controls put
in Master page, its name and id will be mangled. For example, the
following
html control in master page

=========
<input id="hidden1" name="hidden1" runat="server" type="hidden"
value="hidden1 value" />
<input id="hidden2" name="hidden2" runat="server" type="hidden"
value="hidden2 value" />
===========

will be rendered as below finally:

<input name="ctl00$hidden1" type="hidden" id="ctl00_hidden1"
value="hidden1 value" />
<input name="ctl00$hidden2" type="hidden" id="ctl00_hidden2"
value="hidden2 value" />

Thus, on the target page, you can not directly use the original
hiddenfield's name to quey the Request.Form collection. One flexible means
is to query the Request.Form collection and find the one that contains the
hiddenfield's unmangled name. e.g.

========in target page===============

protected void Page_Load(object sender, EventArgs e)
{
foreach (string key in Request.Form.Keys)
{
if(key.Contains("hidden1"))
Response.Write("<br/>" + key + ": " + Request.Form[key]);
}
}
==============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
>

Nov 23 '06 #5
Thanks for your reply Steve,

Please feel free to let me know if you meet any further problem.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 24 '06 #6
Hi,

Steven Cheng[MSFT] wrote:
I think what you mentioned should be "Control.UniqueID" :)
sorry for my posting, I wasn't reading carefully enough and assumed a
client-side thing (i.e. some JavaScript looking for the control). :-P

Cheers,
Olaf
--
My .02: www.Resources.IntuiDev.com
Nov 24 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Christopher Brandsdal | last post: by
5 posts views Thread by Wayne Wengert | last post: by
8 posts views Thread by abcd | last post: by
12 posts views Thread by Mark Rae | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.