CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/5/2007 11:00:54 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 26 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
chrigil
Asp.Net User
Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event11/5/2007 11:00:54 AM

0/0

Can anybody shed any light onto this weird problem which I have experienced before (and had to code around) but finally found the reason for.

If you have a dropdownlist on a page which uses a MasterPage and the EnableViewState is set to false in the MasterPage and then enabled on a page-by-page basis, the DropDownList_SelectedIndexChanged event is fired for all DropDownLists regardless of which one is actually called. It isn't important that the view state is enabled on a page-by-page basis, the important thing seems to be that it is disabled in the masterpage.

This problem is also reported in the following post http://forums.asp.net/p/1163948/1931200.aspx but nobody seems to have an answer.

Any help is appreciated.

Thanks,

Chris

Johnson2007
Asp.Net User
Re: Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event11/6/2007 4:18:03 AM

0/0

 Yes. Because the maserpage has EnableViewState with false, the page will not keep the view state. By default, the SelectedIndex of a DropdownList control will be 0, and SelectedIndex property of RadioButtonList will be -1. If the selected index is not queal to the default value, the SelectedIndexChanged event will always fired. To test it, you can selected the second item or third item ect but not the first one, the event is fired. It is right. and then, select the first item(index=0) of dropdownlist you will find the event will not be fired. Right. the default selectedindex the page remember is 0. Therefore, to solve such problem, the only approach is to set the EnableViewState property of Master and Page to true. If you need to set it to false, I am afraid you have to try to find some way to avoid to set the EnableViewState to false.


Johnson
chrigil
Asp.Net User
Re: Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event11/6/2007 9:29:52 AM

0/0

Thanks for the reply.

I understand what you are saying whereby the check is based on "If selectedIndex is not equal to the defaultvalue then fire the event". Is this always the case or does it only work this way when EnableViewState=false? For example, if EnableViewState=True and I select item 3 and then select item 0, will the event be fired?

Regardless of this however, if I am setting EnableViewState=Flase in the MasterPage, but then set EnableViewState=True in each individual page or on each individual control, why does this not work? Surely the setting on the content page should overwrite the settign of the MasterPage?

Any idea?

Thanks, Chris

Johnson2007
Asp.Net User
Re: Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event11/8/2007 8:48:54 AM

0/0

Actually, master page plays a server control of content page at runtime. Scott Allen says:

For ViewState to be available to a control, it's parent must have ViewState enabled. Since a master page injects itself as the direct child of the Page object, having ViewState disabled in the master page shuts off ViewState for everything inside the Page.

For the entire article please see: http://odetocode.com/Blogs/scott/archive/2006/10/11/7872.aspx 

May this helps you! 


Johnson
Johnson2007
Asp.Net User
Re: Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event11/8/2007 8:57:08 AM

0/0

 hello again,

To solve you problem, I suggest that you don't set EnableViewState="false" in master directive, but set it in Web.config.

<system.web>

   <
pages enableViewState="false"  />

</
system.web>

If the page you mentioned above just set the EnableViewState="true" in Page directive.

more information still see: http://odetocode.com/Blogs/scott/archive/2006/10/11/7872.aspx 


Johnson
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...
Masterpage "EnableViewState=False" Breaks ... Masterpage "EnableViewState=False" Breaks DropDownList_SelectedIndexChanged Event. Last post 11-08-2007 3:57 AM by Johnson2007. 4 replies. ...




Search This Site:










yanp - unable to generate a temporary class

login failed

microsoft visual studio 2005

module print icon causes error

custom membershipprovider and applicationname property

is this possible with imc ?

sqltableprofileprovider - unable to cast object of type 'system.datetime' to type 'system.string'

dual list box control problem

masterpage split table tags - compile error!

text appears larger over https than over http

problem with tttforum

curiosity question... ms access or msde(sql)

asp.net and saving files to network appliance

help! need to convert 9 lines of code!

keeping individual page stylesheets and javascript with a masterpage

dnn connection woes

copied topic :: extending gridview

hate to see this

mark hughes - buzzmarketing book

app_themes in a child application

hi, i have a problem with stylesheets, can you please help me?

requireemail= false is not working

cannot use themes folder for my own use

tabstrip/pageview -- passing parameters

domain username

the form tag's action attribute

unable to center content in some containers?

private child portal

calling parent method from dynamically created child control

printer friendly page using a querystring in masterpage and pagelayouts

 
All Times Are GMT