Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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 August 23rd, 2004, 01:10 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Web Custom Control

Hi All,
   I am designing a web custom control that inherits a third party control. I have added a paroperty to my custom control of type string.When i put the inherited control on my web page and try setting its property through design time property window, i recieved an error saying "specified cast is invalid". However if i set the same property through code-behind, it works fine. Can anyone please tell me what might be going wrong here.

 
Old August 23rd, 2004, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

What scope is this variable?

Brian
 
Old August 24th, 2004, 02:43 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

This variable is exposed as a public property of the web custom control.

 
Old August 24th, 2004, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Maybe mark the property as <Serializable()>. That seems odd...

Brian
 
Old August 24th, 2004, 07:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Also, could you post some code, as that would help also.

Brian
 
Old August 25th, 2004, 06:41 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Brian,

Below is the code of the custom control.




using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace RhealWebPlanner
{
    [DefaultProperty("Text"),
        ToolboxData("<{0}:RhealWebPlanner runat=server></{0}:RhealWebPlanner>")]

    public class RhealWebPlanner : ThirdParty.WebControl
    {
        private string text;
        private string _PopupPage;

        [Browsable(true)]
        [Category("Appearance")]
        [Description("The CSS class name for the read-only version of this control's text.")]


        public string Text
        {
            get
            {
                return text;
            }

            set
            {
                text = value;
            }
        }
        [Bindable(true),
        Category("Appearance"),
        DefaultValue("")]

        public string PopupPage
        {
            get
            {
                return _PopupPage;
            }

            set
            {
                _PopupPage = value;
            }
        }


        protected override void OnInit(EventArgs e)
        {
            this.CellsSelected += new ComponentScience.WebPlanner.PlannerCellsSelectedEv entHandler(RhealWebPlanner_CellsSelected);
            this.EditType = ComponentScience.WebPlanner.EditType.Custom;
            this.SelectionMode = ComponentScience.WebPlanner.SelectMode.MultiSelect ;
            this.AutoDetectCulture = false;
            this.PositionsPerGroup = 1;
            this.OverlapAllowed = false;
            this.Mode.PeriodStartDate = Convert.ToDateTime("06/02/2004");
            this.Mode.PeriodEndDate = Convert.ToDateTime("05/02/2004");
            this.Mode.DayMapping = ComponentScience.WebPlanner.DayMapType.MultiDayRes ource;
            base.OnInit (e);
        }


        private void RhealWebPlanner_CellsSelected(object sender, ComponentScience.WebPlanner.PlannerCellsSelectedEv entArgs e)
        {
            this.Page.Session.Add("RoomID", e.SelectedResource.ResourceID);
            this.Page.Session.Add("CreatorID", 4);

            string script = string.Empty ;
            script = "<script language='javascript'> " +
                "window.open('"+ this.PopupPage +"?Club=27', 'AddMeeting'," +
                "'width=420, height=350, menubar=no, center=yes, resizable=no');" +
                "</script>";
            this.Page.RegisterStartupScript("AddMeeting",scrip t);
        }
    }
}


 
Old August 25th, 2004, 07:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Try setting the Browsable attribute to true, and if you want design time only feature for that property, set the DesignTimeOnly attribute. You can also add an editor; see: http://msdn.microsoft.com/library/de...classtopic.asp

Brian
 
Old August 27th, 2004, 04:46 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

  I tried seeting the Browsable, DesignTimeOnlyAttribute but could not get way with the error.
Also the code on the micsoroft site for providing user interface for selecting a URL, does gives an error saying "The type or namespace name 'Design' does not exist in the class or namespace
'System.Web.UI' (are you missing an assembly reference?)"

Please let me know your suggestions.
Thanks a lot for your help.


 
Old August 27th, 2004, 05:00 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brian,

  I was missing assembly reference for System.Design, which solved the problem of Design class but i am still getting error for "UITypeEditor" class.
  Also there are some properties that i want to publish as string types.

 
Old August 27th, 2004, 05:04 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

 UITypeEditor was also an assembly issue, which is solved and the now property shows user interface for selecting a URL but still getting the error "Specified cast is not valid."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Web Service, Custom Control, Custom Return Type robzyc ASP.NET 2.0 Basics 6 June 10th, 2008 08:03 AM
Web Custom Control - Color Picker Property elwappo ASP.NET 2.0 Professional 0 January 31st, 2008 08:37 AM
Web Custom Control Events junshi ASP.NET 1.0 and 1.1 Professional 1 May 3rd, 2007 01:19 AM
Render Window Media Player in a web custom control pratik28 General .NET 0 June 8th, 2006 07:49 AM
Maintaining the viewstate in a custom web control cridley C# 0 February 20th, 2006 07:55 AM





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