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 / Building Controls / June 2007

Tip: Looking for answers? Try searching our database.

View State Null In IPostBackHandler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark - 08 Jun 2007 16:59 GMT
Hi,

I had a datetimepicker server control that worked great in 1.x but I am
having trouble with it in ASP.NET 2.x  For some reason, the ViewState value
is always null on postback so IPostBackDataHandler.LoadPostData is unable to
access the properties correctly.  Is there a change I should make?  Here's
the iPostBackHandler code:

        void IPostBackDataHandler.RaisePostDataChangedEvent() {
            //OnSelectedIndexChanged(System.EventArgs.Empty);
            OnDateChanged(System.EventArgs.Empty);
        }

        bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection) {

// when it access the SelectedDate here, its ViewState value is null

            DateTime PreviousSelectedDate = SelectedDate;
            DateTime DateSubmitted = SelectedDate;

// other code

}

The code for the SelectedDate property is

        [
        Description("Gets or sets the date for the DateTimePicker control."),
        Category("Appearance"),
        //DefaultValue(),
        Bindable(true),
        ]
        public virtual DateTime SelectedDate
        {
            get
            {
                object savedSelectedDate;

                savedSelectedDate = this.ViewState["SelectedDate"];
                if (savedSelectedDate != null)
                    return (DateTime) savedSelectedDate;
                return DateTimeNotSet;
            }
            set
            {
                this.ViewState["SelectedDate"] = value;
            }

        }

I've checked and EnabledViewState is not set to false on the page or
controls.  Any suggestions?

Signature

Sincerely,

Mark Fox

Walter Wang [MSFT] - 11 Jun 2007 09:11 GMT
Hi Mark,

I'm not aware of the IPostbackDataHandler has changed much in 2.0.

I also tried the code examples of book "Developing Microsoft? ASP.NET
Server Controls and Components" here
http://www.microsoft.com/mspress/books/companion/5728.aspx which was
previously built with VS2002. The SimpleTextBox which demonstrates
IPostBackDataHandler works fine in VS2005.

Please post more of your control's code to see if it's related to its
implementation. Thanks.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Mark - 11 Jun 2007 19:44 GMT
Hi Walter,

Thank you for your response!  You are correct that IPostBackHandler wasn't
changed in ASP.NET 2.0.  After looking at this more I found that the problem
was caused by a deep bug somewhere else.  I am sorry for the inconvenience
and thank you for your help!

Signature

Sincerely,

Mark Fox

> Hi Mark,
>
[quoted text clipped - 19 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
Walter Wang [MSFT] - 12 Jun 2007 04:25 GMT
Hi Mark,

You're welcome. I'm glad to know that you've solved the issue.

Have a nice day!

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

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.