Dynamic Enum With Intellisense?
Oct 6, 2010
I know this is asking alot...and as far as I know there is no way to do this..but I still tought that I whould ask you guys if you might some how figured this one out. The thing is that I have a database-table that contains information about different user-roles...and I whould like to retrive each roles-name in an enum..and as the data changes in teh table I whould like the enum to change aswell...and I also whould like
it to be possible to actually get intellisense once trying to access the enum..
I have looked at the following link and sulotion:[URL] The problem with that as far as I have understod, is that I dont get the intellisense and the code kind of gets even harder to understand...since the whole point with enums is to make the code easy to understand..atleast as far as I know.
View 5 Replies
Similar Messages:
Sep 28, 2010
whats wrong with this code, i try also Enum.Parse but didnt work.
public enum RoleNames
{
Administrator,
[code]...
View 1 Replies
Jan 6, 2010
I think my main problem is actually more to do with master pages that anything else.. Below is a description:
If you use master pages in your website and you have pages in different sub directories then the simplest way to add JQuery references is using <script src='<%# ResolveUrl ("jq.js")%> /> in the master page header??
This means that the .js files are correctly referenced in all pages that use the master. My main problem is that intellisense only seems to work for JQuery when the JQ Script is actually referenced in the header and not by using ResolveUrl('') <script src="/scripts/jq.js" />
I dont want to have to live without intellisense, Surely there is a way to get around this. What am I doing wrong.
View 1 Replies
Feb 12, 2011
I am facing an critical problem in Enum serialization in WCF. Here is the scenario: I have an enum like this...
[Serializable] [DataContract(Namespace = "http://www.geniusdoc.portal.com/serivces/2011/v1/GdService", Name = "AppointmentMode")] public enum AppointmentMode : int { // 1: Email, 2: Phone [EnumMember(Value = "1")] None = 1, [EnumMember(Value = "2")] Email = 2, [EnumMember(Value = "3")] Phone = 3 }
Here I decorated each enum value with [EnumMember], so that I can use the Enum as Data Contract in WCF.
And, AppointmentMode will be saved as INTEGER in database. So I need to serialize this Enum to its value. So I have specified value to each member like... [EnumMember(Value = "1")]
Problems:
If I use the above code as it is...SvcUtil not considering Enum Text, and generating the Enum in Proxy as below...
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] [System.Runtime.Serialization.DataContractAttribute(Name="AppointmentMode", Namespace="http://www.geniusdoc.portal.com/serivces/2011/v1/GdService")] public enum AppointmentMode: int { [System.Runtime.Serialization.EnumMemberAttribute(Value="1")] _1 = 1, [System.Runtime.Serialization.EnumMemberAttribute(Value="2")] _2 = 2, [System.Runtime.Serialization.EnumMemberAttribute(Value="3")] _3 = 3, }
If I remove the Value from [EnumMember(Value = "1")], while deserialization is considering Enum Text, and giving results as below
<AppointmentMode>None</AppointmentMode>
Expected result:
1. Enum in the Client proxy should be same original Enum.
2. Enum Deserialization should consider EnumValue, such a way that it will return
<AppointmentMode>1</AppointmentMode>
How to get this done?
View 5 Replies
Jan 23, 2010
i have tables like Lookup and lookupvalues in the lookup table like and lookup values like
LookupId LookupName | lookupValueId lookupId Name
1 Country | 1 1 Usa (country)
2 State | 2 2 All(state)
3 Relation | 3 2 Colarado (state)
4 3 agenttoClient(relation)
now i want create enum class form databse
my req is
enum lookup{
Country,state,Relation(these should be come from Databse when ever application intialised)
}
now i able acces lookupvalues
lookup.country.1=>USa
lookup.State.1=>All
lookup.State.2=>Colorado
lookup.Relation.1=>Agent to client
View 1 Replies
Apr 28, 2010
i am fresher, so i want to learn Enum deeply.
What is enum, when to use it and why to use it?
Because i want to clear from basic. Infact i want to become my basic concepts strong in OOPS, Collections.
View 4 Replies
Aug 31, 2010
i need to display the name of enum in gridview by data table returns its numeric value
i am using this for other columns
<asp:BoundField DataField="Name" HeaderText="User Name" />
i need to use it for enum to display the string value of enum Gender
<asp:BoundField DataField="Gender" HeaderText="Gender" />
View 1 Replies
Feb 9, 2011
I'd like to mimic the behavior of the "profile provider" that is available in .Net. The profile provider acquires profile properties from the web.config and those properties are immediately available as an enum for use in the code behind.I'm unsure how to do this, and wondered whether someone may be able to help.Essentially I'd like to allow developers to enter Role information into the web.config, and then have this role information available for use within an enum in the codebehind.
View 2 Replies
Jun 23, 2010
If have the following enum
public enum EmployeeType
{
Manager = 1,
TeamLeader,
Senior,
Junior
}
and i have DropDownList and i want to bind this enum to it .. is it any way to do that ?
View 1 Replies
Mar 22, 2011
I want to add the below values from Enum to drop down list
<option value="0">-- Select --</option>
<option value="AC">Active</option>
<option value="IN">InActive</option>
<option value="PC">Pending Closure</option>
View 2 Replies
Jan 22, 2010
Can we access an enum which has been defined in the master page. I read about the master page on [URL]
View 1 Replies
Mar 14, 2010
I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "name". Is there a way to get the enum as a string in my json without having to create a custom JavaScriptConverter? Perhaps there's an attribute that I could decorate the enum definition, or object property, with?As an example:
enum Gender { Male, Female }
class Person
{
[code]...
View 2 Replies
Apr 26, 2010
I would like someone to explain how I can pass a drop down list from the presentation layer to the controller using the Model View Controller Design Pattern from Microsoft in order to bind enum values to it?
View 2 Replies
Mar 17, 2011
I have a linqdatasource and I want to use an enum for Type as below:
<asp:linqdatasource id="GridDataSource" runat="server" enabledelete="true" Where="Type == @Type">
<whereparameters>
<asp:dynamiccontrolparameter controlid="FilterRepeater" />
<asp:QueryStringParameter QueryStringField="Type" Name="Type" ConvertEmptyStringToNull="false" />
</whereparameters>
</asp:linqdatasource>
It keeps throwing an error:
Operator '==' incompatible with operand types 'ProductType' and 'String' ProductType is my Enum, and String is my input type. I don't seem to be able to convert one to the other.
View 2 Replies
May 11, 2010
if it is possible to extend the ASP.NET HtmlTextWriterTag Enum so that it includes HTML 5 tags? Specifically 'section' and aside' tags at the moment.
I'm trying to create a control which inherits from the Panel Control, but instead of it writing a tag I want it to write either a an 'aside' tag or a 'section' tag dependant on a property on the control.
I'm stuck using Web forms and VB.NET, so if the solution could take that into account it'd
[EDIT]
In the past I have changed the outer HTML tag of a panel by using the following code (this would render 'li' tags instead of a 'div' tag):
Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag
Get
Return HtmlTextWriterTag.Li
End Get
End Property
I'm struggling to make this render a as a 'section' or an 'aside' tag though. I can get the control to render...
<div>
<section>
</section>
<div>
...but the perfectionist in me just wants to render...
<section>
</section>
View 1 Replies
Sep 3, 2010
I have a class like this
public class MyClass
{
public MyClass()
[code]...
but in my view i keep having this eror
"The value 'System.Collections.Generic.List`1[MyEnum]' is not valid for Enumlist"
I did not specify any validation attribute for the property EnumList, so i don't why the automatic error.
View 2 Replies
May 19, 2010
I have a data object named Usertype. The Database table is also called Usertype. I need to have an enum representing Usertypes also. What would proper naming convention be for the Usertype Enum? It can't be Usertype. But I can't append an E or "Enum" to it anywhere. What would be the proper name for the Enum?
View 3 Replies
Mar 29, 2011
I am populating a page with controls reading properties of a class using reflection. If the property type is 'String' I will add a text-box. If the property type is enum I am adding a dropdownlist. Now I have to populate the dropdown options with enums. How can this be done?
Both the enum definition class(Assignment) and the class(classOne) using which I am populating the page with controls are in the same Namespace(MySolution.Data). While looping through classOne properties when the property name is 'SkillLevel' I will have to go to assignment class get the members of enum SkillLevelEnum and populate the dropdown.
Same needs to be done for other dropdowns also.
My Code:
namespace MySolution.Data
{
public class classOne : MyAdapter
{
private string _Model;
[code]....
View 4 Replies
Mar 1, 2011
I have a enum
[Code].....
This I have to bind in my dropdown so how can I achieve this.
View 10 Replies
Aug 20, 2010
I have an application which has rows of data in a relation database the table needs a status which will always be either Not Submitted, Awaiting Approval, Approved, Rejected Now since these will never change I was trying to decide the best way to implement them I can either think of a Status enum with the values and an int assigned where the int is placed into the status column on the table row.
Or a status table that linked to the table and the user select one of these as the current status.
I can't decide which is the better option as I currently have a enum in place with these values for the approval pages to populate the dropdown etc and setup the sql (as it currently using to Approved and submitted for approval but this is dirty for various reasons and needs changed).
Wondering what your thought on this were and whether I should go for one or the other.
If it makes any difference I am using Entity framework.
View 3 Replies
Jul 1, 2010
i have a model:
[Code]....
and in my controller, i have:
[Code]....
and this ViewData contains the information of a type of List<SelectListItem>,which can be used to generate a dropdownlist in the view later on. BUT, now i want to write a function in my controller to generate List<SelectListItem> based on different input enum, what like want to do is like this:
[Code]....
however, there are so many errors.
View 2 Replies
Mar 28, 2010
I m trying to create a custom textbox with a enum kind property in it(like textmode).the enum values will come from database..but enums cant be dynamic..is there another way out??
View 3 Replies
Feb 8, 2011
i am generating a wcf data contract from a schema, using svcutil /d: option, however the enum of type xsd:int in schema is generating all the values as ints, with underscores, obviously to make valid code. How can i get the actual value of 1000
E.g Enum Impact with values 1000,2000,3000 generates code
public enum Impact : int
{
[System.Runtime.Serialization.EnumMemberAttribute(Value = "1000")]
_1000 = 1,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "2000")]
_2000 = 2,
[System.Runtime.Serialization.EnumMemberAttribute(Value = "3000")]
_3000 = 3
}
View 2 Replies
May 19, 2010
I am getting this build error on the following line of code, and do not find anyhting wrong there.
public partial class _Default : System.Web.UI.Page
{
}
[code]...
View 3 Replies
Jun 18, 2010
Let's say I have a function that takes a string. That string contains the fully name of an enum type (e.g. "MyCompany.Area.AotherNamespace.MyEnum").
How could I create an array of strings (or List<string>) whose elements are the values of MyCompany.Area.AotherNamespace.MyEnum?
Is that even possible?I'm basically trying to serialize an enum type serverside and then output it in clientside JavaScript so I don't have to define an enum in two places--in my C# and my JavaScript.
View 1 Replies