473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 11562
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Christopher Brandsdal | last post by:
Hi! I get an error when I run my code Is there any other way to get te information from my form? Heres the error I get and the code beneath. Line 120 is market with ''''''''''''Line...
5
by: Wayne Wengert | last post by:
I am trying to use Request.Form to differentiate between when a page containing a form is first loaded and when it is reloaded as a result of the user clicking on the Submit button. Things are not...
4
by: Paxton | last post by:
At the risk of being told "If it ain't broke, don't fix it", my code works, but is ugly. Part of the admin site I'm working on at the moment includes a facility for users to enter Formulations...
5
by: Jack | last post by:
Hi, I am trying to get a thorough understanding of a code where a addition or deletion of records can be done from a list of records. For addition part of the form, data is being obtained from set...
2
by: Joseph James | last post by:
Hi all, I am very new to ASP.net. As I was going through new features of asp.net, I came across Masterpage and I tried to use it. But when the form is posted to another page, the key names of the...
8
by: abcd | last post by:
I can get the value on the form at the server side by using Request.form("max") when max field is disabled I dont get value. For GUI and business logic purpose I have disabled some fields with...
4
by: whyyyy | last post by:
USING IIS 5.1, and Windows XP pro, the following form works on my system, and I can use as many form elements as I wish, as long as all form elements have the same name: "words", in this example....
4
by: Michael Kujawa | last post by:
I am using the following to create an SQL statement using the names and values from request.form. The loop goes through each item in request.form The issue comes in having an additional "and" at...
12
by: Mark Rae | last post by:
Hi, See the previous thread Request.Form abuse in this newsgroup... I'm looking for a simple and efficient way to prevent people hijacking the <formtags on my websites and using them to send...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.