Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2004, 02:23 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default LoadPostData()

Hello,

Creating a control that uses the IPostBackDataHandler interface, is it possible to load more than one property using LoadPostData()? All of the examples only load one. For example:

http://www.dotnetjunkies.com/quickst...ion1.vb&font=3

How do you do it?

Thanks,

Brian
__________________
Brian
 
Old November 1st, 2004, 04:31 AM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Brian,

I stumbled into the same problem as you did while developing a composite servercontrol for handling dates. After some brainwork I found a solution on how to access the different values of the childcontrols in the control.
I know you are talking about properties, but this solution works fine for me and might give you a hint on how to solve your problem.

Best regards - Dan
Code:
        bool IPostBackDataHandler.LoadPostData(string postDataKey, 
            NameValueCollection values) 
        {

            DateTime postedValue; 

            _year = (values[postDataKey + ":cboYear"] != null ? (int)System.Convert.ToInt16(values[postDataKey + ":cboYear"]) : -1);
            _month = (values[postDataKey + ":cboMonth"] != null ? (int)System.Convert.ToInt16(values[postDataKey + ":cboMonth"]) : -1);
            _day = (values[postDataKey + ":cboDay"] != null ? (int)System.Convert.ToInt16(values[postDataKey + ":cboDay"]) : -1);
            _hour = (values[postDataKey + ":cboHour"] != null ? (int)System.Convert.ToInt16(values[postDataKey + ":cboHour"]) : -1);
            _minute = (values[postDataKey + ":cboMinute"] != null ? (int)System.Convert.ToInt16(values[postDataKey + ":cboMinute"]) : -1);

            if(_year==-1&&_month==-1&&_day==-1&&_hour!=-1&&_minute!=-1)
            {
                _currentDateTime = System.Convert.ToDateTime(values[postDataKey + ":inputCurrentDateTime"]);

                _year = _currentDateTime.Year;
                _month = _currentDateTime.Month;
                _day = _currentDateTime.Day;
            }

            if(_year!=-1&&_month!=-1&&_day!=-1&&_hour!=-1&&_minute!=-1)
            {
                postedValue = new DateTime(_year, 
                _month, 
                _day, 
                _hour, 
                _minute, 0);

                this.SelectedDate = postedValue;

                return true;
            }
            return false;
        }









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.