473,231 Members | 1,621 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,231 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 11555
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.