Home All Groups Group Topic Archive Search About

Retrieving Values from Hidden Fileds Inside Web Controls on PostBa

Author
6 Mar 2006 5:01 PM
Frank Buchan
Hi, all.

I'm pretty sure some event in my old brain is refusing to fire, and I'm
hoping someone can kick start what's left of my grey matter.

The abstract issue I'm having is this:

I have a web control that works perfectly. On the client-side it hides and
shows different sections of the interface (simple DIV tags), and it manages
this without postback. It uses a hidden field successfully to let the
JavaScript know what DIV block was previously displayed, so it can hide it
successfully when the next link is clicked. Conceptually, it amounts to a tab
control set where each tab displays one of a set of DIV blocks.

It works perfectly, except when postback is fired it "forgets" which link
was selected. The end result is the first link in the set is set to focus,
with the correct page being displayed, etc.

What I have been trying to do is read the posted value of the hidden field
as set by the client (as posted back), but the problem is the hidden field
the control renders is simply not being posted back at all so far as I can
tell.

The web control is not composite, and renders everything as HTML, including
the hidden field.

Now, I am certain I've forgotten the obvious, so my question is this: What
are the reasons a hidden field rendered within a server control would be
written correctly to the client side, work correctly, but fail to post back
changed data?

I suppose I could revise the web control to use some form of composite, but
other than this quirk it is functioning acceptably, and I'm keen to fidn an
answer to why this is so, etc.

Any thoughst are appreciated. Thanks in advance.

Author
6 Mar 2006 5:47 PM
Patrice
No name attribute, disabled, not inside the form tag are the main reasons I
can think that would cause the field not be posted.

I would start by dumping the request.form collection to see if technically
speaking it is posted. If not try to see the HTML source client side to
check what goes wrong with this field. If yes, it could be perhaps a problem
when the posted values are retrieved from Request.Form by the ASP.NET
infrastructure.

Good luck.
--
Patrice

Show quoteHide quote
"Frank Buchan" <FrankBuc***@discussions.microsoft.com> a écrit dans le
message de news:829A7F09-42E2-4C03-B5D7-6F17EC1A4051@microsoft.com...
> Hi, all.
>
> I'm pretty sure some event in my old brain is refusing to fire, and I'm
> hoping someone can kick start what's left of my grey matter.
>
> The abstract issue I'm having is this:
>
> I have a web control that works perfectly. On the client-side it hides and
> shows different sections of the interface (simple DIV tags), and it
manages
> this without postback. It uses a hidden field successfully to let the
> JavaScript know what DIV block was previously displayed, so it can hide it
> successfully when the next link is clicked. Conceptually, it amounts to a
tab
> control set where each tab displays one of a set of DIV blocks.
>
> It works perfectly, except when postback is fired it "forgets" which link
> was selected. The end result is the first link in the set is set to focus,
> with the correct page being displayed, etc.
>
> What I have been trying to do is read the posted value of the hidden field
> as set by the client (as posted back), but the problem is the hidden field
> the control renders is simply not being posted back at all so far as I can
> tell.
>
> The web control is not composite, and renders everything as HTML,
including
> the hidden field.
>
> Now, I am certain I've forgotten the obvious, so my question is this: What
> are the reasons a hidden field rendered within a server control would be
> written correctly to the client side, work correctly, but fail to post
back
> changed data?
>
> I suppose I could revise the web control to use some form of composite,
but
> other than this quirk it is functioning acceptably, and I'm keen to fidn
an
> answer to why this is so, etc.
>
> Any thoughst are appreciated. Thanks in advance.
Author
6 Mar 2006 9:19 PM
Frank Buchan
Thanks, Patrice.

I confirmed it was enabled, and was inside the form tag. My mind must be
slipping, though, as I had forgotten entirely about the name attribute.
Though it was set, I hadn't considered looking there.

Most embarrassing of all, I never even had a single neuron fire off the
obvious suggestion to check the darn Request object. I will do that as soon
as I get a chance, as it is likely to reveal exactly what is happening.

Again, thanks very much.

Show quoteHide quote
"Patrice" wrote:

> No name attribute, disabled, not inside the form tag are the main reasons I
> can think that would cause the field not be posted.
>
> I would start by dumping the request.form collection to see if technically
> speaking it is posted. If not try to see the HTML source client side to
> check what goes wrong with this field. If yes, it could be perhaps a problem
> when the posted values are retrieved from Request.Form by the ASP.NET
> infrastructure.
>
> Good luck.
> --
> Patrice
>
> "Frank Buchan" <FrankBuc***@discussions.microsoft.com> a écrit dans le
> message de news:829A7F09-42E2-4C03-B5D7-6F17EC1A4051@microsoft.com...
> > Hi, all.
> >
> > I'm pretty sure some event in my old brain is refusing to fire, and I'm
> > hoping someone can kick start what's left of my grey matter.
> >
> > The abstract issue I'm having is this:
> >
> > I have a web control that works perfectly. On the client-side it hides and
> > shows different sections of the interface (simple DIV tags), and it
> manages
> > this without postback. It uses a hidden field successfully to let the
> > JavaScript know what DIV block was previously displayed, so it can hide it
> > successfully when the next link is clicked. Conceptually, it amounts to a
> tab
> > control set where each tab displays one of a set of DIV blocks.
> >
> > It works perfectly, except when postback is fired it "forgets" which link
> > was selected. The end result is the first link in the set is set to focus,
> > with the correct page being displayed, etc.
> >
> > What I have been trying to do is read the posted value of the hidden field
> > as set by the client (as posted back), but the problem is the hidden field
> > the control renders is simply not being posted back at all so far as I can
> > tell.
> >
> > The web control is not composite, and renders everything as HTML,
> including
> > the hidden field.
> >
> > Now, I am certain I've forgotten the obvious, so my question is this: What
> > are the reasons a hidden field rendered within a server control would be
> > written correctly to the client side, work correctly, but fail to post
> back
> > changed data?
> >
> > I suppose I could revise the web control to use some form of composite,
> but
> > other than this quirk it is functioning acceptably, and I'm keen to fidn
> an
> > answer to why this is so, etc.
> >
> > Any thoughst are appreciated. Thanks in advance.
>
>
>
Author
6 Mar 2006 11:08 PM
Frank Buchan
Here I go replying to my own post.

Again, thanks to Patrice for the reminder to check the Request.Forms
collection, as it led me to a different path of thinking and the actual
problem. For anyone who might experience a similar problem:

If the hidden field is not appearing to post back, examine the Request.Forms
collection immediately. In my case that was all it took for me to realize it
was posting back, and to ask the next logical question: Why wasn't the
client-side change to the field being restored to the control?

That question led me to look into the control more closely, scratch my head
because LoadPostData was being overridden, and slap my forehead when I
noticed I had forgotten to indicate the control was to participate in the
postback process. I added the correct code to its Init event
(RegisterRequiresPostBack) and it is now working exactly as desired.

Sometimes the simplest oversight, and way too much time staring at the code,
boils down to looking away from where you think the problem might be.

Show quoteHide quote
"Frank Buchan" wrote:

> Hi, all.
>
> I'm pretty sure some event in my old brain is refusing to fire, and I'm
> hoping someone can kick start what's left of my grey matter.
>
> The abstract issue I'm having is this:
>
> I have a web control that works perfectly. On the client-side it hides and
> shows different sections of the interface (simple DIV tags), and it manages
> this without postback. It uses a hidden field successfully to let the
> JavaScript know what DIV block was previously displayed, so it can hide it
> successfully when the next link is clicked. Conceptually, it amounts to a tab
> control set where each tab displays one of a set of DIV blocks.
>
> It works perfectly, except when postback is fired it "forgets" which link
> was selected. The end result is the first link in the set is set to focus,
> with the correct page being displayed, etc.
>
> What I have been trying to do is read the posted value of the hidden field
> as set by the client (as posted back), but the problem is the hidden field
> the control renders is simply not being posted back at all so far as I can
> tell.
>
> The web control is not composite, and renders everything as HTML, including
> the hidden field.
>
> Now, I am certain I've forgotten the obvious, so my question is this: What
> are the reasons a hidden field rendered within a server control would be
> written correctly to the client side, work correctly, but fail to post back
> changed data?
>
> I suppose I could revise the web control to use some form of composite, but
> other than this quirk it is functioning acceptably, and I'm keen to fidn an
> answer to why this is so, etc.
>
> Any thoughst are appreciated. Thanks in advance.