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 > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 9/1/2004 8:56:49 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 43 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
MLibby
Asp.Net User
Web Custom Control - Enum Property Question ? ? ?9/1/2004 8:56:49 PM

0/0

I'm building a web custom control in which I'm trying to include an enum for one of the properties as follows:

//-------------------------
public enum LocationType
{
NotSet,
Client,
Server,
Both
}

[
Category("ACFragment Defaults"),
DefaultValue(LocationType.Client),
Description ("location where the content is stored"),
DesignerSerializationVisibility (DesignerSerializationVisibility.Content),
NotifyParentProperty(true)
]
public virtual LocationType ACDefaultLocation
{
get
{
object o = ViewState["ACDefaultLocation"];
return (o == null) ? LocationType.Client : (LocationType)o;
}
set
{
ViewState["ACDefaultCacheLocation"] = value;
}
}
//----------------------

The enum correctly displays as a drop down in design mode and once selected the value shows up correctly in the html design form. However, when the application runs the control always retrieves the default value rather then the value selected in the drop down.

My guess is that I'm missing Enum.ToObject(typeof(LocationType), value) in the get method. However, that would cause problems in the design mode.

I've seen references to TransitionStyleObjectConverter in this forum which should help but I can't figure out how to implement it into the above scenario.

Please let me know how to make this work,
Mike


- Cache entire web sites at the client and server and keep cache current. Cache just got easier!
AndrewSeven
Asp.Net User
Re: Web Custom Control - Enum Property Question ? ? ?9/2/2004 1:09:59 AM

0/0

You setter and getter don't use the same key for ViewState ;)
MLibby
Asp.Net User
Re: Web Custom Control - Enum Property Question ? ? ?9/2/2004 3:00:21 AM

0/0

Slip in the example, its the same in the code though.
- Cache entire web sites at the client and server and keep cache current. Cache just got easier!
master4eva
Asp.Net User
Re: Web Custom Control - Enum Property Question ? ? ?9/2/2004 2:17:00 PM

0/0

Look at the bolded stuff here ;-) :

object o = ViewState["ACDefaultLocation"];

And

ViewState["ACDefaultCacheLocation"] = value;

Don't you hate weakly typed dictionaries? :-)
-- Justin Lovell
MLibby
Asp.Net User
Re: Web Custom Control - Enum Property Question ? ? ?9/3/2004 1:27:11 PM

0/0

Thanks mater4eva,

That wasn't the problem but rater a slip when coping my code to the forum. I appreciate your input though.

The problem was the use of NotSet in the enum which kept taking the default value making me think the enum wasn't working. It seems that the "NotSet" enum value is a particular value for webcontrol, it will be parsed by the asp.net runtime as "not set", so that the default value of that property will be set. You can find the same behavior of the other control's "Font" or anyother Properties. Change NotSet to None in the enum and it works!

Mike
- Cache entire web sites at the client and server and keep cache current. Cache just got easier!
5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Mastering Visual Studio .NET Authors: Ian Griffiths, Jon Flanders, Chris Sells, Pages: 397, Published: 2003
Application Development Using Visual Basic and .NET Authors: Robert J. Oberg, Peter Thorsteinson, Dana L. Wyatt, Pages: 830, Published: 2002
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Pro .NET 2.0 Windows Forms and Custom Controls in VB 2005 Authors: Matthew MacDonald, Pages: 1036, Published: 2006
Windows Forms Programming in Visual Basic .NET Authors: Chris Sells, Justin Gehtland, Pages: 680, Published: 2003
MCAD/MCSD Training Guide (70-316): Developing and Implementing Windows-Based Applications with C# and Visual Studio. NET Authors: Amit Kalani, Ed Tittel, Pages: 1200, Published: 2002
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006

Web:
Web Custom Control - Enum Property Question ? ? ? - ASP.NET Forums Re: Web Custom Control - Enum Property Question ? ? ? 09-01-2004, 9:09 PM. Contact ... Re: Web Custom Control - Enum Property Question ? ...
Custom Property Sample
Notice the syntax for setting the enumeration property and the subproperties.

Rory Primrose | Creating Web Custom Controls With ASP.Net 1.1 ... Creating Web Custom Controls With ASP.Net 1.1 - Part III - Using Metadata Attributes ... Enum properties also have a bit of an interesting behavior. ...
Setting a Custom Control Property that is an enumeration (or other ... Setting a Custom Control Property that is an enumeration (or other non primative type) from aspx page. Get answers to your questions in our ...
radio button - Enum - DataBinding question : radio, button, enum Hello, I have a custom object that I am binding to a user control. The control will have 3 ... Then my custom object has a property that holds an enum. ...
CodeProject: Eventing Within Composite Web Custom Controls. Free ... Handling events and View State inside a Web Custom Control using ... Then, make a property that will return that enum type, and the designer takes care of ...
Enum properties not applying to the custom control - ASP.NET Forums I have a custom control for which there is an enum property. ... Questions / Problems with this site? Visit our hoster: ORCS Web ...
15 Seconds : Customizing SharePoint Web Parts with Custom ... This sample contains a DataGrid control which displays customer information. ... I expose this enum class as a Web Part custom property as display below, ...
Web part custom property - dropdown list Dec 19, 2007 ... A dropdown list will now appear in the miscellaneous section of your web part custom properties containing the enum values. ...
Web Content Management ASP ASP.NET Reference Topics Sep 30, 2005 ... Using a Custom Control on a Page Exposing a Property: The PrimeGenerator Control Example ... Declarative Syntax for Enumeration Properties ...




Search This Site:










prevent multiple logins to my website.

forms authentication

centering controls within webparts

restricting access to a virtual directory?

i need a good html text editor for dnn 2.12 that works in firefox

expanded menu problem in ie 7 only

adding child control to calendar loses selectevalue on postback

c# equivalent to php "die"?

free modules list http://cathal.europe.webmatrixhosting.net/ is not available! where is the new location?

login problem with asp 2.0 web service

copy dnn content to another dnn site

logging into a secure page within a site

general exception on search indexing

security temporary asp.net files

module definition not appearing

how do you skin a new aspx page?

caching search results from database

role authorizing deadlock

1st install...1st problem

how to initiate a process with client credentials??

dotnetnuke only shows me the source code!

simple login

i cant change module type definition !

weather module v1.2 for dnn3 released

hiding module dropdown but keep edit link

webparts error!

failed on installing .net framework 3.5

behavior of news list on the home page

system.data.sqlclient.sqlexception: login failed for user

asynchronous insert

 
All Times Are GMT