Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

EnableViewState strange behaviour ???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Peeters - 09 Aug 2007 12:31 GMT
Hi,

I have a listBox listed with colornames and a panelcontrol that takes
the color of selecteditem from the listbox whenever I click a different
item:

 protected void lstColors_SelectedIndexChanged(object sender, EventArgs
e)
 {
   pnlColor.BackColor =
       Color.FromName(lstColors.SelectedItem.Value);
  }

The panelcontrol draws correctly whenever I click in the listbox but
when I click on another button on the webform the panelcontrol looses
its color although EnableViewState is set to true for the panelcontrol.

Its only when I set the EnableViewState of the listBox to false that the
panelcontrol keeps its state (no matter what the EnableViewState of the
panelcontrol is set to) ???

how do you explain this strange behavior ?

thank you
Chris
Eliyahu Goldin - 09 Aug 2007 13:35 GMT
> The panelcontrol draws correctly whenever I click in the listbox but
> when I click on another button on the webform the panelcontrol looses
> its color although EnableViewState is set to true for the panelcontrol.
Do you set the panel in some initial color in the Page_Load event? Do you
check IsPostBack property before doing that?

> Its only when I set the EnableViewState of the listBox to false that the
> panelcontrol keeps its state (no matter what the EnableViewState of the
> panelcontrol is set to) ???
Setting EnableViewState to false disables firing events. Check if you have
any event handling code that could cause this behavior.

Signature

Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.