473,408 Members | 1,784 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,408 software developers and data experts.

Retrieving a HTML Element's Value via Request.Params

As you all know the value of input, checkbox and other "user editable"
elements can be retrieved on postback via Request.Params list, if you
know their ID.

However, if there is a span element (for example) whose value gets
updated via javascript when the user does something, that value is not
made available as part of the Request.Params list. Persumably because
"span" is not considered a "editable" element and it's value is not
sent back on postback. Is there a way to force this to happen?

I am developing a composite control which gets rendered within a span
element and I need to retrieve the value of this element on postback
vis Request.Params.

The composite control is not yet "constructed" at the time I want to
retrieve it's value during post-back, so I have lookup the
Request.Params list to get it's value.

-Praveen

Nov 19 '05 #1
6 2553
Hello Praveen,

HtmlHiddenField are good for that. With javascript make a copy of the value
in an hidden field, this one will be posted and be "catchable from server
side code".

Hope that help.

--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"Praveen" <rp******@yahoo.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
As you all know the value of input, checkbox and other "user editable"
elements can be retrieved on postback via Request.Params list, if you
know their ID.

However, if there is a span element (for example) whose value gets
updated via javascript when the user does something, that value is not
made available as part of the Request.Params list. Persumably because
"span" is not considered a "editable" element and it's value is not
sent back on postback. Is there a way to force this to happen?

I am developing a composite control which gets rendered within a span
element and I need to retrieve the value of this element on postback
vis Request.Params.

The composite control is not yet "constructed" at the time I want to
retrieve it's value during post-back, so I have lookup the
Request.Params list to get it's value.

-Praveen

Nov 19 '05 #2
JC,

Thanks for the response.
Yes, I thought about that, but I didn't like that idea for the
following reason:
1) I will have to assing the hidden field a DIFFERENT id, probably
derived from my control's id.
2) Then when I distribute this control (for reuse) I will have to ask
the user to look up the value based on this hidden field's id rather
than the control's id. I found this non-standard and inelegant.

I am concerned that this is the approach I might have to end up taking
though :(

-Praveen

Nov 19 '05 #3
Praveen,

You can make composite control with very friendly api and interface that
will hide completely that. You can make a property that will "hide" the
hidden field variable mechanism.

As for Id and reusability, implement INamingContainer and all sub controls
will be assign unique id automatically even if using inside another control,
usercontrol and just multiple instance on the same page.

Hope that help,

--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"Praveen" <rp******@yahoo.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
JC,

Thanks for the response.
Yes, I thought about that, but I didn't like that idea for the
following reason:
1) I will have to assing the hidden field a DIFFERENT id, probably
derived from my control's id.
2) Then when I distribute this control (for reuse) I will have to ask
the user to look up the value based on this hidden field's id rather
than the control's id. I found this non-standard and inelegant.

I am concerned that this is the approach I might have to end up taking
though :(

-Praveen

Nov 19 '05 #4
JC,

Yes, the user wouldn't have to deal with the hidden fields. But, when
it comes to retrieving the latest "value" they will nevertheless have
to do something like this:

// On Postback at some point:

string compositeControlID = GetCCID(); // I can only get the CC's ID
here based on some logic as the Control itself is not constructed yet.

// Since my composite control control would be using a hidden field to
store the latest value, I will have to look for that hidden field
instead, so:
string hiddenCompositeControlFieldID = compositeControlID +
"valueField"; // "valueField" is advertised to be the suffix you should
add to arrive at the hidden field ID (This got ugly already :( )

// Now retrieve the latest value:
object newValue = Request.Params[hiddenCompositeControlFieldID];

I hope I made myself clear.

Thanks
-Praveen

Nov 19 '05 #5
In a perfect Object-Oriented world, the user who want the value of the
hiden-field value control ask the composite control the value (not by using
global Request.Param[]. So only the composite control do the dirty job in a
property that will wrappe the code you type below.
It's only a point of view.

--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"Praveen" <rp******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
JC,

Yes, the user wouldn't have to deal with the hidden fields. But, when
it comes to retrieving the latest "value" they will nevertheless have
to do something like this:

// On Postback at some point:

string compositeControlID = GetCCID(); // I can only get the CC's ID
here based on some logic as the Control itself is not constructed yet.

// Since my composite control control would be using a hidden field to
store the latest value, I will have to look for that hidden field
instead, so:
string hiddenCompositeControlFieldID = compositeControlID +
"valueField"; // "valueField" is advertised to be the suffix you should
add to arrive at the hidden field ID (This got ugly already :( )

// Now retrieve the latest value:
object newValue = Request.Params[hiddenCompositeControlFieldID];

I hope I made myself clear.

Thanks
-Praveen

Nov 19 '05 #6
Jc,

Yes, that's true. But, like I mentioned the control is not yet
constructed at this point.

I guess I will have to do it this way.

-Praveen

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chris Shipley | last post by:
I am trying to present a list of links on a page (Form) where each link opens a different picture gallery. I have the Form page which contains the links, a Gallery page, and several include files....
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
5
by: MLibby | last post by:
How can you tell when you've reached an elements end tag? For example, how can the following code tell that <MenuItem Label="Overview" ClientSideOnClick="CacheDemo/IntroToCache.ascx"/> has an end...
2
by: Kevin | last post by:
I am attempting to fetch the value of a paramter passed in on the http request url. Example: http://localhost.mypage.aspx?ID=12345 In the URL above I am wanting to retrieve the value of the...
2
by: Lee | last post by:
I have an xml Structure: <?xml version="1.0" encoding="utf-16"?> <Request> <Operations> <Command> <OpType>login</OpType> <Params> <UserName>leebo</UserName> <Password>leebo</Password>
2
by: robert112 | last post by:
This is quite a hard one guys. ***Some necessary back ground Info*** I have an asp.net 1.1 application that uses a WYSIWYG to return some html created by the user in the admin section of the...
0
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
9
by: ajos | last post by:
Hello friends, After thinking about this for sometime, i decided to post this in the java forum. Well my problem here in detail is, i have 3 jsp pages where in a.jsp(for example) i have a combo...
4
by: Nick Vargish | last post by:
Hi, I'm a little bit stuck trying to send a SOAP request that includes multiple occurrences of an element. For the sake of illustration, this is what the relevant portions of the SOAP request...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.