Listbox styles lost while postback

Last post 08-03-2009 9:42 AM by eleserpent. 3 replies.

Sort Posts:

  • Listbox styles lost while postback

    08-02-2009, 6:24 AM
    • Member
      2 point Member
    • eleserpent
    • Member since 09-20-2007, 8:05 AM
    • Posts 7

    Hi all

    I have a listbox inside a updatepanel. And have the onSelectedIndexChanged event on this listbox where i do some other opration.

    Whenver there is a postback due to SelecteIndexChanged the attributes(stlyes) set to this listbox are gone.

    foreach (ListItem objListItem  in objListItems)
    {

        if(something) objListItem.Attributes.CssStyle.Add("color", "#F68933");


    }

    I found that this a bug in ASP.NET AJAX   https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=103134

    Is there any other workaround for this. Or am i doing everything correct.


    Any help is appreciated, thanks in advance.

    Thanks

  • Re: Listbox styles lost while postback

    08-02-2009, 4:06 PM

    does it need to change on every post back... or can you use the

    if (!Page.IsPostBack)   <- IF PAGE IS NOT POSTBACK

    or

    if (Page.IsPostBack)

    and skip the page trying to reinterpret?


    protected void Page_Load(object sender, EventArgs e)   // - Things you want to happen only during initial pageload

    {

    if (!Page.IsPostBack)  // Things you want to happen at every postback / pageload.

    {

    }

    }


    C#


  • Re: Listbox styles lost while postback

    08-02-2009, 11:12 PM
    Answer
  • Re: Listbox styles lost while postback

    08-03-2009, 9:42 AM
    • Member
      2 point Member
    • eleserpent
    • Member since 09-20-2007, 8:05 AM
    • Posts 7

    Thanks for the link. Will try it out.

    This worked for me thanks.

Page 1 of 1 (4 items)