How To Create Enum Class
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
Similar Messages:
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
Sep 28, 2010
whats wrong with this code, i try also Enum.Parse but didnt work.
public enum RoleNames
{
Administrator,
[code]...
View 1 Replies
Aug 11, 2010
I am getting the same error (as this post: http://forums.asp.net/p/1346731/4020966.aspx) as expected class,delegate,enum,interface or struct and also type or namespace definition or end of file expected.Below is the code:
public
partial
class
[code]...
View 1 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
May 19, 2010
Should we create a class for every form we create,that will us to do the validations etc etc?
View 1 Replies
Jul 23, 2010
All I want to do is learn how to create a class procedure. And then. How to call it. As an example, A + B = C is the procedure. I would create a class. Right? Then do I name the procedure and put it in the class? Or create a new class for each procedure? Then I would want to, on a local level, substitue values for A & B to return C. So, if the public procedure exists, how to I call it? I know that this is really simple stuff, but I need examples to be simple.
View 1 Replies
Sep 24, 2010
I am trying to create a pageBase class where I can dynamically pull data from the database and display it on a web page. Each page I specifically set an ID for the sql query which pulls back the information such as page title and page text.
my problem is that I can't seem to pass the information captured from the query to the page. I get problems such as can't convert string type to literal and I need to declare a new keyword to an object.
PageBase Class
Csharp Code:
[code]....
View 3 Replies
Apr 4, 2011
A instance of a class is created in the partial class of an aspx page.Under page_load or button click method I'm trying to set the value to the class. but when each postback takes place new instance is created and I'm losing the previous value.
public partial class DatabaseSelection : System.Web.UI.Page
{
DBProperties dbpro;
Metadata obmeta;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
dbpro = new DBProperties();
}
View 4 Replies
Jan 26, 2011
My ultimate goal is to create a UserControl in a class in my App_Code folder and render the html from that into a string.
The rending of HTML can be done using this example I believe:
How do I get the HTML output of a UserControl in .NET (C#)?
My Question:
I created my user control
public partial class Controls_MyUserControl : System.Web.UI.UserControl
I've registered it in my web.config
<add tagPrefix="UC" src="~/Controls/MyUserControl.ascx" tagName="MyUserControl" />
I can reference this on a page just fine
<UC:MyUserControl ID="MyUserControl1" runat="server" />
Yet when I try to create an object of this control type in a class (in my app_code folder) it doesn't allow me.
Controls_MyUserControl dummy = new Controls_MyUserControl();
The potentially strange thing is when I put this code into a code behind of a page, it works.
what I need to do to have the usercontrol to be able to be created in my class in the app_code folder?
My guess is, is that I need to reference the control in a "using" statement at the top, but I'm not sure what that'd be.
It's not in a namespace to my knowledge (at least there's no namespace, in the code behind of the actually user controls). Though I'm not sure if it inherits one from the System.Web.UI.UserControl.
View 1 Replies
Sep 18, 2010
I am using vs 2010, mvc, linq to sqlMy Model is .dbmliletbl_teacher,tbl_class,tbl_subject etc are involvedI write code in my controller for table join.
[Code]....
View 5 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
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
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
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
Apr 10, 2010
i have a table ("WebSettings") that have some information about Website like what is the name of website which theme use and so on i want to creat a class to return the website settings can you give me some information obot what is the best way in this case to get the informations and how can i creat this class?
View 1 Replies
Feb 24, 2010
I am using Visual Studio 2008 with .Net 2.0
I am maintaining and old application in ASP.Net and it has one CustomGridView control with 4000 lines of code. I see that in that file only, when I try to modify any code the IDE does not respond quickly as it does for other files. I thought of creating partial classes for the same but it seems that VS is not reconginzing the new partial class. I am trying to use the variables from the old partial class and it is not able to reconize any variable or method.
View 5 Replies
Feb 26, 2011
May i know how to create Component class in asp.net.i was used the following code in VB.net but inASP.net there is no Componentclass file in
Add->Newitem
(how to create textbox with only your can enter numbers only)
My code to create text that only accept Number and also some color change.................
Public Class ZillisisNumberTextBox
Inherits TextBox
Private Sub ZillisisNumberTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Enter
Try
Me.BackColor = Color.LemonChiffon
Me.Font = New System.Drawing.Font("Verdana", 8.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ZillisisNumberTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
Try
If Not IsNumeric(e.KeyChar) And e.KeyChar <> System.Convert.ToChar(Keys.Back) And e.KeyChar <> System.Convert.ToChar(Keys.Delete) Then
e.Handled = True
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ZillisisNumberTextBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
Try
Me.BackColor = Color.White
Me.Font = New System.Drawing.Font("Verdana", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
View 11 Replies
May 24, 2010
i want create a class Library work with SQL Linq ,when i create a LINQ Data Class it automatic create some connectionString and use the database namemy question is can i change some settings that, use this class Library in difrent website with difrent connectionStrings?
View 6 Replies
May 21, 2010
I wanna do smth like this:
[Code]....
Does anyone have a recommendation how this is archievable? I am trying to pass in the Type to the method and then create an instace of it and then access the properties in it.
View 8 Replies
Mar 20, 2010
I have a bit of code I am reusing on a lot of my pages so decided to put this code into a Class and placed this class inside the App_Code directory. However when ever I try and create an instance of tis class so that I can use it's Methods etc I can't seem to get it to work, but if I create the class in the web root for the project it all wrks as expected.
View 12 Replies
May 21, 2010
I was wondering is it possible to create a css class at runtime?
I am unable to use the traditional method of doing so as one of the attributes need to be loaded at runtime.
As I am using the Coolite Toolkit, whenever i need to use a custom image onto one of the controls, the custom image path needs to be loaded in via a stylesheet class.
View 2 Replies
Apr 16, 2010
I am trying to create instance of class by using reflection in ASP.net web site. Class ClassName is defined and located in App_code folder. Following line returns null, what could be wrong.
Type type = Type.GetType("NameSpace.ClassName", false, true);
View 5 Replies
Aug 4, 2010
I have a search page that is used in multiple places with multiple 'themes' throughout my site. I have a few divs that can have their background color changed based on a radio button selection (whether they are enabled or not). I can do this just fine by changing the css class of the div on the fly with javascript.
However, these themes could potentially change, and the background color is grabbed from a database when the page is created. Right now I do this in the C# codebehind:
string bgStyle = "background-color:" +theme.searchTextHeaderColor +";";
OwnerSearchHeader.Attributes.Add("style", bgStyle);
In the Javascript I need to change this color to make it look disabled, and when the user clicks back to this div I need to re-enable it by changing it back to its original color. But since I only knew this color in the code-behind, I don't know what it was in the Javascript.
So my thought was to create a css class in the resulting HTML page when the page is loaded with the background color I need. Then I could simply switch from the divEnabled and divDisabled class in the javascript. But I'm not exactly sure how to do that.
View 2 Replies