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: 10/27/2003 7:07:01 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 16 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
coolkin
Asp.Net User
adding property10/27/2003 7:07:01 PM

0/0

Hi,

I'm new to creating web custom controls. I'm trying to add a property of type enum to my web custom control. Ideally, at design time, that property can be accessed by a dropdownlist.

Anybody has a list of good tutorials on creating web custom controls such as adding design time features?

Thanks.
Andy Smith
Asp.Net User
Re: adding property10/27/2003 9:13:56 PM

0/0

If your property is an enum, vstudio will automaticly show a dropdownlist of the enum's values to select from.

For Instance:

public enum MyChoice {
Foo, Bar
}

public class MyControl : WebControl {
public MyChoice ChosenChoice {
get {
object savedState = ViewState["ChosenChoice"];
if ( savedState != null ) {
return (MyChoice)savedState;
}
return MyChoice.Foo;
}
set {
ViewState["ChosenChoice"] = value;
}
}


That ChoseChoice property will show in the propertygrid in the designer as a dropdownlist containing Foo and Bar.
SomeNewKid
Asp.Net User
Re: adding property11/5/2003 7:22:47 AM

0/0

To extend this thread ... doesn't using an enum in this way cause an ASP.NET page problems?

For example, <Prefix:MyControl MyChoice="Foo" runat="server" /> throws the exception that the attribute MyChoice needs to be of type enum MyChoice (where it's currently of type String)?

I'm presuming, Andy, that you are the author is this Flagged Enum Properties blog entry, which addresses this mentioned.

Following your guide, my TextBox server control has ended up like this (trimmed):
Imports System


Namespace e3.Web.UI

Public Class xTextBox
Inherits e3.Web.UI.xWebControl
Implements System.Web.UI.IPostBackDataHandler

' Constructors
Public Sub New()
TagName = "input"
End Sub

' Properties (among others)
Private Property _textBoxMode As e3.Web.UI.TextBoxMode
Get
Dim ThisMode As Object
ThisMode = Me.ViewState( "TextBoxMode" )
If Not ThisMode Is Nothing Then
Return CType( ThisMode, e3.Web.UI.TextBoxMode )
Else
Return e3.Web.UI.TextBoxMode.SingleLine
End If
End Get
Set
Me.ViewState( "TextBoxMode" ) = Value
End Set
End Property
Public Property TextBoxMode As String
Get
Return _textBoxMode.ToString()
End Get
Set
Try
_textBoxMode = CType([Enum].Parse( GetType( e3.Web.UI.TextBoxMode ), Value, True ), e3.Web.UI.TextBoxMode )
Catch
_textBoxMode = e3.Web.UI.TextBoxMode.SingleLine
End Try
End Set
End Property

' Methods
Protected Overrides Sub OnPreRender( ByVal eArgs As EventArgs )
' if the TextBoxMode is MutliLine, then we need to change the TagName to "textarea"
If TextBoxMode.ToLower() = "multiline" Then TagName = "textarea"
End Sub

End Class


' Enums
Public Enum TextBoxMode
SingleLine
MultiLine
Password
End Enum

End Namespace

Is this indeed still the best way to handled enum Properties? Or has a simpler solution presented itself?

(Either way, thanks for your blog, Andy, since it stopped me pulling my hair out.)
Alister
Andy Smith
Asp.Net User
Re: adding property11/5/2003 4:00:41 PM

0/0

you only need to do the hack if it's a flagged enum, meaning multiple values are supported. If it's a single-item enum. the original code is fine.
SomeNewKid
Asp.Net User
Re: adding property11/5/2003 4:10:42 PM

0/0

Thanks for the explanation (particularly as enums are new to me).

And, more importantly, thanks for the blog entry to which I referred earlier.
Alister
leoleo
Asp.Net User
Re: adding property6/13/2006 7:41:27 AM

0/0

Hi Andy,

i have an urgent question for you. i read your article: 32692 about adding multiple selection for a flagged enum, it looks quite good but i guess i'm missing something.

i'm working in vs2005,c#, and i've created an asp server control. i added some properties and it's works great. the problem is that i want the ability to select multiple values (flaaged enum) to a single propery by selecting it at design time at the html editor.

for example:  if i have an enum:

[flags]

public enum test : int

{

none = 0,

a=1,

b=2,

c=4

}

how do i declare my property and how do i make the html editor to show me all the choices for selecting more that one at design time! waiting for your answer, i'm stuck!!!

Thanks,

Leo.

6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Make Your Own Living Trust Authors: Denis Clifford, Pages: 349, Published: 2007
Plan Your Estate Authors: Denis Clifford, Pages: 548, Published: 2008
101 Law Forms for Personal Use Authors: Robin Leonard, Ralph Warner, Pages: 368, Published: 2007
AARP Crash Course in Estate Planning: The Essential Guide to Wills, Trusts, and Your Personal Legacy Authors: Michael T. Palermo, American Association of Retired Persons, Pages: 272, Published: 2004
Critical and Historical Essays, Contributed to the Edinburgh Review Authors: Thomas Babington Macaulay, Pages: 412, Published: 2001

Web:
Adding Property Pages (Windows) For more information about property sheets, see the Platform Software Development Kit (SDK). This topic discusses adding property pages to a snap-in using ...
Adding Property Pages and Wizard Pages (Windows) A property sheet is a window that allows the user to view and edit the properties of an item.
Adding property listings to a real estate Web site with WebSite ... It streamlines entering property information. The new page wizard makes the process as quick and easy as possible. After selecting the page type, click Add ...
'Adding property.key support?' - MARC [prev in thread] [next in thread] List: log4j-dev Subject: Adding property.key support? From: Ceki =?iso-8859-1?Q?G=FClc=FC? ...
SPA Process User's Guide, June 2006, Chapter 4 - Adding Property ... Note: Before adding a property record, obtain the necessary property and .... Note: When adding property records using q, be sure every field ...
Bookshelf v8.0: Adding Property Coverages and Coverage Limits The Property Coverage Administration view allows you to add and make changes to property coverages and property coverage limits. ...
Training: Adding property income and expenses : Bia Creations Dec 20, 2007 ... The training session for tonight has to do with adding income and expenses to properties. You can keep track of all of your property ...
adding property sheet to "open with" dialog I created a file association for the .bak file and I want to make the default action to open the windows properties sheet dialog.
The NT Insider:Property - Adding Property Pages to Device Drivers Property - Adding Property Pages to Device Drivers The NT Insider, Vol 8, Issue 3, May-Jun 2001 | Published: 15-Jun-01| Modified: 30-Jul-02 ...
Residential Property Management: adding property management to ... Jan 17, 2008 ... property management firm, property management business, property management company: Hi Edward, and thanks for your question.

Videos:
Adding in a Residential For Sale Property Listing To get started, visit http://www.PropBot.com This video will show you how to add in a residential property listing that is for sale within the PropB...
How to Add Property listing to BuzzProperties.co.uk Lesson o how to add property listing to BuzzProperties.co.uk
Adding in a Residential For Rent Property Listing To get started, visit http://www.PropBot.com This video will show you how to add in a residential rental property listing within the PropBot.com sys...
Adding in File Attachments to Your Property Listing This video will show you how to upload file attachments to your Property Listing. This will allow you to attach a spreadsheet, document, PDF document...
Impressions Systems- Adding your Property on a Nominated Travel Portal Impressions Systems- Adding your Property on a Nominated Travel Portal, Property management system, Reservation Management
Adding in a Commercial For Lease Property Listing To get started, visit http://www.PropBot.com This video will show you how to add in a commercial for lease property listing within the PropBot.com s...
Adding in a Commercial For Sale Property Listing To get started, visit http://www.PropBot.com This video will show you how to add in a commercial for sale property listing within the PropBot.com sy...
How to Add Property Photos to BuzzProperties.co.uk In this lesson we learn how to add property photos to your property listing in BuzzProperties.co.uk
theVacationHouse - Adding a Property Adding a Property on theVacationHouse.com
Courthouse Foreclosure Property Auction: DROdio Attends We attended several courthouse auctions to highlight how the home foreclosure and auction process works. Includes extended commentary from auctionee...




Search This Site:










change server name from localhost

paypal sandbox?

submit login button

211 upgrade complile error

customer customization using web parts? is this the best technology for this?

hide errors from visual studio 2005 error list

menuadapter beta 2

mapquest maps.....(falafel map)

accessing active directory

hard-coded roles

contentpager removed?

help, cannot logon after publish a web application

desktop module load code in source code?

copying userpersonalizationstateinfo

formsauthentication and session

dnn 3.05 handling of querystring

manually set skin to default??

detect that user needs a different role to access a page or folder, and issue a message instead of just going to login page.

htaccess

retrieving file from current portal skin directory

css in page settings

accessing mapped network shares using asp.net

block external links to my website's page display

unable to cast object of type 'asp.' to type ''

document module won't upload ppt file

how to add client javascript to treenode click event?

recurring installation error

adding new features from extended cs to existing club site instance?

hide "site" skin and container folders from file manager.

works local but not after publlishing

 
All Times Are GMT