 |
| 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
|
|
|
|

August 23rd, 2004, 01:10 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 23rd, 2004, 08:06 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
What scope is this variable?
Brian
|
|

August 24th, 2004, 02:43 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Brian,
This variable is exposed as a public property of the web custom control.
|
|

August 24th, 2004, 07:17 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
Maybe mark the property as <Serializable()>. That seems odd...
Brian
|
|

August 24th, 2004, 07:20 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Hey,
Also, could you post some code, as that would help also.
Brian
|
|

August 25th, 2004, 06:41 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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);
}
}
}
|
|

August 25th, 2004, 07:34 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

August 27th, 2004, 04:46 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 27th, 2004, 05:00 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 27th, 2004, 05:04 AM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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."
|
|
 |