hidden inputs and viewstate

Discussion in 'ASP .Net' started by dawidg, Jun 11, 2008.

  1. dawidg

    dawidg Guest

    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">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /
    >

    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
    value="" />
    <input type="hidden" name="h_ctl14" id="h_ctl14" value="" />
    <input type="hidden" name="h_ctl16" id="h_ctl16" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="...=" /
    >

    </div>



    Why are these h_* inputs created?
    dawidg, Jun 11, 2008
    #1
    1. Advertising

  2. 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>
    Michael Nemtsev [MVP], Jun 11, 2008
    #2
    1. Advertising

  3. dawidg

    bruce barker Guest

    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)


    "dawidg" wrote:

    > 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&TableId=10&ViewType=1" id="form1">
    > <div>
    > <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /
    > >

    > <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT"
    > value="" />
    > <input type="hidden" name="h_ctl14" id="h_ctl14" value="" />
    > <input type="hidden" name="h_ctl16" id="h_ctl16" value="" />
    > <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="...=" /
    > >

    > </div>
    >
    >
    >
    > Why are these h_* inputs created?
    >
    bruce barker, Jun 11, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ellie
    Replies:
    2
    Views:
    439
    Ellie
    Oct 30, 2008
  2. Pif
    Replies:
    1
    Views:
    519
    Jukka K. Korpela
    Dec 22, 2009
  3. Rick
    Replies:
    3
    Views:
    8,095
    Alexey Smirnov
    Apr 13, 2010
  4. Replies:
    15
    Views:
    706
    Alan J. Flavell
    Dec 30, 2004
  5. SolarCanine
    Replies:
    2
    Views:
    251
    SolarCanine
    Sep 20, 2005
Loading...

Share This Page