Re: Radio Buttons in a Repeater Control

Discussion in 'ASP .Net' started by Jeroen Klooster, Apr 7, 2004.

  1. Hi all!

    Setting the groupname with javascript works ok for me.
    In my case however, I also want the radiobutton to autopostback when
    the checked state is changed. This works fine too, but it doesn't keep
    the viewstate of the radiobutton. When I check a radiobutton, a
    roundtrip occurs, and when the page is loaded again, the radiobutton
    is unchecked.
    Any idea how to solve this issue?

    Regards,
    Jeroen Klooster
     
    Jeroen Klooster, Apr 7, 2004
    #1
    1. Advertising

  2. Well, it's the age old problem of dynamic controls being added too late in
    the web control hierarchy to participate in view state. The easiest way is
    to recreate it. Otherwise you will have to add it very early in the
    webcontrol hierarchy.

    --
    Regards,
    Alvin Bruney [ASP.NET MVP]
    Got tidbits? Get it here...
    http://tinyurl.com/27cok
    "Jeroen Klooster" <> wrote in message
    news:...
    > Hi all!
    >
    > Setting the groupname with javascript works ok for me.
    > In my case however, I also want the radiobutton to autopostback when
    > the checked state is changed. This works fine too, but it doesn't keep
    > the viewstate of the radiobutton. When I check a radiobutton, a
    > roundtrip occurs, and when the page is loaded again, the radiobutton
    > is unchecked.
    > Any idea how to solve this issue?
    >
    > Regards,
    > Jeroen Klooster
     
    Alvin Bruney [MVP], Apr 7, 2004
    #2
    1. Advertising

  3. Thanks for your reply!

    I don't think that is the issue, because when i do not set the "name"
    attribute with javascript for these radiobuttons, the viewstate wíll
    be kept. Any other clues what might be causing this?

    Kind regards,
    Jeroen
     
    Jeroen Klooster, Apr 8, 2004
    #3
  4. Hi Jeroen,

    I think this is because the "name" attribute of the ASP.NET rendered server
    controls has its meaning to mapping its parent control(container controls)
    so that at serverside it can help identify it , also may help mapping its
    viewstate info. If we manually modify it at client, these control's
    viewstate association at serverside will be corrupted just like if we
    change the "__VIEWSTAET" hidden name's name at client via javascirpt, the
    whole page's viewstate will be corrupted. Do you think so? Thanks.


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
     
    Steven Cheng[MSFT], Apr 10, 2004
    #4
  5. Hi Steven,

    Thanks for your reply. I figured it would be something like that. So
    this is a bug you HAVE to work around. I do not use the javascript
    currently: when a radiobutton is checked, the page will autopostback
    and I will bind the repeater which contains the radiobutton controls
    again. This assures there is only one radiobutton checked.
    Two downsides:
    - It needs another query to the database.
    - (picky but true), before autopostback, after radiobuttoncontrol is
    checked, for a brief moment, two radiobuttons will be checked.

    But I guess this will be the only way.

    Regards,
    Jeroen
     
    Jeroen Klooster, Apr 13, 2004
    #5
    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. SouthSpawn

    Radio Buttons in Repeater Control

    SouthSpawn, Aug 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,187
    Karl Seguin
    Aug 14, 2005
  2. Replies:
    0
    Views:
    622
  3. Scott D Johnson
    Replies:
    1
    Views:
    1,075
    Scott D Johnson
    Sep 27, 2006
  4. Dr. Leff
    Replies:
    3
    Views:
    299
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    231
    David Mark
    Oct 15, 2007
Loading...

Share This Page