hidden inputs and viewstate

D

dawidg

I have an asp.net page with viewstate disabled. I have a control on
the page that dynamically creates controls inside itself, no
viewstate. The controls aren't created in Init, but in Load.

With Viewstate disabled, a few hidden inputs appear in the beginning
of the page, all name h_*. Nowhere in my code do I create these. The
problem is that these hidden input create errors on postback if my
controls doesn't create the same number of controls. this is the
error:

An error has occurred because a control with id 'ctl14' could not be
located or a different control is assigned to the same ID after
postback. If the ID is not assigned, explicitly set the ID property of
controls that raise postback events to avoid this error.


Here's the inputs I'm talking about:
<body>
<form name="form1" method="post" action="Module.aspx?
tvid=32&amp;TableId=10&amp;ViewType=1" id="form1">
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
value="" />
<input type="hidden" name="h_ctl14" id="h_ctl14" value="" />
</div>



Why are these h_* inputs created?
 
M

Michael Nemtsev [MVP]

Hello dawidg,

There is no such controls by default.
Try to create empy page to verify that.

Do u use any 3rd party libs?

---
WBR,
Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


d> I have an asp.net page with viewstate disabled. I have a control on
d> the page that dynamically creates controls inside itself, no
d> viewstate. The controls aren't created in Init, but in Load.
d>
d> With Viewstate disabled, a few hidden inputs appear in the beginning
d> of the page, all name h_*. Nowhere in my code do I create these. The
d> problem is that these hidden input create errors on postback if my
d> controls doesn't create the same number of controls. this is the
d> error:
d>
d> An error has occurred because a control with id 'ctl14' could not be
d> located or a different control is assigned to the same ID after
d> postback. If the ID is not assigned, explicitly set the ID property
d> of controls that raise postback events to avoid this error.
d>
d> Here's the inputs I'm talking about:
d> <body>
d> <form name="form1" method="post" action="Module.aspx?
d> tvid=32&amp;TableId=10&amp;ViewType=1" id="form1">
d> <div>
d> <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value=""
d> /
d> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
d> value="" />
d> <input type="hidden" name="h_ctl14" id="h_ctl14" value="" />
d> <input type="hidden" name="h_ctl16" id="h_ctl16" value="" />
d> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="...="
d> /
d> </div>
d>
d> Why are these h_* inputs created?
d>
 
B

bruce barker

you are using a 3rd party control that creates hidden fields based on its
name. as you have not assigned an id to the control, it assigned by the
server. on postback you are not creating the controls in the same order, so
the names are different. just explicitly name the controls.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top