creating htmlinputhidden dynamically in code-behind, but values not posting back to client.
Posted on 2006-04-29
My aspx page only holds a content tag and an asp: form tag with "name="myform" method="post". Using master page of course.
In the code-behind I'm creating a label object, an htmlinputhidden object, and a radiobutton object.
I don't have the code in front of me while I"m writing this but here's some psuedo-code.
On PostBack take care of form inputs, read the values and process then do below again, if needed
Loop for x records
Set value in htmlinputhidden.value (have also used .attributes.add("value", SomeInt.tostring))
Loop for RAdioButtons
Sub Add List Items (radiobuttons.controls.add(New LIst Items)
Assign ID's to all objects
The first time the page is sent to the client the values on the hidden field are exactly what they are suppose to be when viewing source. I process those values on return to server during postback, then call the subroutine that gets a new set and displays them. When the subsequent pages are loaded the values are exactly the same as the first page. I have tried putting these in Page_init, prerender, preInit, and everything else. I read the data, then create new objects with new values. The labels.text values change properly, the radio buttons and list items they use hold the correct text and values. What is going on with the htmlinputhidden control ? Everything else works like a charm.
I'm at wits end. I absolutely need those hidden field values. It's like using header and detail records. That value id's my header to the radiobutton detail. Is viewstate messing with this field ? Is there a hidden container I can use to gather this data ? What am I not doing that is not allowing me to use this necessary tool for programming on the web ?
Any help would be a godsend at this point. I'm using vb.net 2.0/asp.net 2.0.