C# - What Is The Best Place To Store Constants In N-tiers App

Dec 31, 2010

I wonder what is the best place to store the enums I should use like constants in my n-tiers Application.

So I have an application with a DAL(connect to database), a BLL(Business processes), a Data Transfert object "Layer" (classes without any methods but just fields, this one is reacheable by all the others) and the interface layer with the asp pages.

My question is : I have a enum:

[code]....

Where can I put this enum(and all the others) to be clean? Not in the Data Access Layer the Interface layer will not see the struct, not in the Business Logic Layer, this is not really business.. Maybe in the Data Transfert Object but is it really a "Transfert object"?

View 7 Replies


Similar Messages:

Can Use A Resource File To Store Page Name Constants

Oct 22, 2010

How can i use the .net Default folder App_GlobalResources Folder to store a Resource file which contains all the Page names?

Currently i added a a Resource file (PageNameConstants.resx) and set the name filed and Value field but i cannot access any of those by calling

App_GlobalResources.PageNameConstants.HOME(HOME has the value ~/Home.aspx)

View 1 Replies

DataSource Controls :: An`t Store Values To A Place For Change Them

Jun 11, 2010

I have problem with retrieve value from Microsoft Access (MDB)..

I want get a value from Database and change it and Store it (Updated Value) again..

For example, I have number 2 in my DB, i want get it and Add 1 to it and store number 3 (Updated number 2) again..

I use SELECT Command but i can`t store values to a place for change them..

View 2 Replies

Security :: Place To Store The User Logged-in ID (info) For Later Checking And Use?

Feb 1, 2010

I have read the post at http://forums.asp.net/t/1403132.aspx regarding login control. Is there a place to store the User logged-in ID (info) for later checking and use? I don't need to use the session object. I don't need the page to expire. I don't need the user to use a page saved in the favoites.

View 3 Replies

Security :: Is There A Way To Set Up 2 Tiers Of Roles

Mar 22, 2010

In our system now, we have a class of user and beneath each class, there's a type of user.

Is there a way to setup and use the ASP.Net role provider with this kind of setup?

View 2 Replies

Segregating To 3 Tiers From Existing Project / Maintain Various Other Web.config Key Values

Apr 4, 2011

In my asp.net project currently i have business logic and and data access code in two sub folders(BLL,DAL) which are itself located web site project's app_code folder. I need to segregate them to two separate projects(one project for business layer and one project for Data access code).

How can I maintain connection strings necessary to Data access project which are currently in web.config file?(i.e if I choose Class library template for creating DAL and BLL projects) How can I maintain various other web.config key values that are currently used in BLL, DAL code files?How can I deploy compiled project? (ie Web site project I am currently deploying bin folder to Staging> production but this way where should i put DAL.dll and BLL.dll and relevant config files)

View 5 Replies

Master Pages - Where's The Best Place To Store Custom "User" Object For The Duration Of Session

Jul 6, 2010

I have an ASP.NET application that needs to remember some info about a user (and what company they are from) across pages, within a session. I imagine this is a requirement of just about any ASP.NET application of a certain size. I've used a few different approaches over the years. In the past, I've passed around an id in querystring parameters like so: [URL] and then instantiated the object on each page (from the database). Another common way of doing it is storing my objects in session variables:

Session["User"] = currentUser; // store at login
User currentUser = (User)Session["User"]; // retrieve on some other page

which saves a trip to the DB, but I worry about memory used if the User object is complex and the site has many concurrent users. I have recently inherited an application that uses public properties on the master page, like this:

Master.theUser = currentUser; // store at login
User currentUser = Master.theUser; // retrieve on some other page

This saves the cast, and looks more readable to me I think, but I don't know if it's better or worse performance-wise. It also has some logic in the getter where if the private value is null, it tries to get it from the Session variable, though I'm not sure if that's never used (or used every get!?) or what. My latest idea is to use my page class. I have a custom page class derived from the standard System.Web.UI.Page base class. It includes objects like CurrentUser as public properties. This seems to work OK. I like it even better. But I really don't know what's going on under the covers. Can anyone give an opinion on which approach is better and why?

Update: I've done some checking use trace.axd and Trace.Write and it looks like neither the masterpage version nor the custom page class version "remember" the values between pages. The "get" methods have a line of code that checks if the User property is null, and if so, reads it from the session variable. This happens when a page accesses the property (Master.User or the derived class's this.User) for the first time on a given page, then subsequent requests can get the value (without going to the session variable). So thus far the best solution looks something like this:

public class MyPage : System.Web.UI.Page
{
private User user;
public User User
{
get
{
if (user == null)
{
user = (User)HttpContext.Current.Session["CurrentUser"]; //check if session[CurrentUser] is null here and log them out if so?
}
return user;
}
set
{
user = value;
HttpContext.Current.Session["CurrentUser"] = value;
}
}
}

Then on any webpage.aspx.cs, you can do something like this: UsernameTextBox.Text = User.FullName;

View 2 Replies

Create A File Of Constants In Javascript?

Jun 30, 2010

Is there a way to create a file of constants in JavaScript, which I can reference and then use?
What I am looking for is something like this:

Constants.js:
var Phones =
{
Nokia: 1,
Samsung: 2
}

Then, in another JavaScript file JS2.js access those values:

JS2.js:
alert(Phones.Nokia);

And then, in an aspx file that uses them, reference both of them, like:

<asp:ScriptReference Path="../js/JS2.js" />
<asp:ScriptReference Path="../js/Constants.js" />

Is such an architecture possible? What datatypes can we use? I only exemplified enums because this is what i use right now, but they must be declared in the same file as they are used.

View 2 Replies

VS 2010 - WebMethod Accessing Local Constants?

May 31, 2013

I am doing an AJAX call back to a WebMethod but in the code behind webmethod I cannot use any of the constants at the to of my form. What I want is to gain access to sessions and my sql connection string.

View 12 Replies

Create Multiple Preprocessor Constants In WebPage Directive?

Mar 8, 2010

It is possible to create a constant like this:

[URL]

<%@ Page CompilerOptions="/d:QUUX" %>

How to create multiple constants ?

View 1 Replies

Architecture :: Create A Constants Mapping Of Strings From Database?

Dec 8, 2010

I have a database table that contains list of all UserTypes(constant strings) used in the application.

What is the best way to store(what datastructure do I need) these so that code can access them ?

The need is similar to enum, but I want to associate these values to those in DB so that there will not be 2 places to edit in case of adding/removing an entry.

one other option I considered is using public static readonly string, but how to associate with those values in DB ?

View 3 Replies

How To Place Two Controls In The Same Place And Alternate Between Them

Apr 1, 2011

I want to place two datalist controls at the same (x,y) position. When the first is visible, second should be invisible.

How would I go about implementing this?

View 2 Replies

Reference Path - Want To Know What "<% =QDAB.Constants.SiteURL %>" Means

Aug 27, 2010

I want to know what "<% =QDAB.Constants.SiteURL %>" means in the following line of code in my aspx page. I did google and didn't really find any information on this.

<td align="center" style="background-image: url(<% =QDAB.Constants.SiteURL %>images/Docs/Plans/myImage.jpg);

So what exactly does this mean?

[Aditional Details]

I changed url(<% =QDAB.Constants.SiteURL %>images/Docs/Plans/myImage.jpg);

to this url(<% =QDAB.Constants.SiteURL %>images/myImage.jpg);

I copied myImage in the "Images" folder.

Why would it access the image from "Images" folder BUT NOT "Images/Docs/Plans"?

View 3 Replies

How To Store Store Procedure Results In A Dataset When There Are 3 Sql Datasets Returned

Mar 11, 2011

My SQL stored procedure returns 3 different datasets as follows:

team_id name
1 Team1
2 Team2
...and more

location_id name
1 Dallas
2 New York
...and more

branch_id name
1 Austin
2 New Jersey
...and more

How do I put this data into one Dataset so that I can loop through the data and manipulate it?

View 1 Replies

Architecture :: Best Way To Implement Online Ordering For A Store Store Already Built?

Mar 19, 2010

hey folks I got a general question that maybe some of you can just weigh in. I developed an online store for a client and people place orders online for a food ordering place however I am trying to find the best way to have the orders show up for them at the store. Currently I am sending an email and an autoprint software prints it out which works most of the time but not good enough sometimes it doesn't print. Anyone had similar issues or have other alternative solutions you may have heard off? Like I said the site sends an email to the customer and the store's email account.

View 7 Replies

Forms Data Controls :: Store Gridview Datatable In Session And Then Retrieve From Session And Store Database

Nov 11, 2010

Its related to datatable in gridview store in session and then session retrive and store to database. basically i am using gridview here creating new row for button click and these row adding untill user's last entry then submit all these entry to database. so i want to use session variable to store this data temporarily and after final entry user click on submit button and all data shold be save in db.

View 9 Replies

DataSource Controls :: Store Images Directly In A Database Or To Just Store The Name Of The File In The Db And Display That File?

Mar 25, 2010

Is it better to store images directly in a database or to just store the name of the file in the db and display that file? I would think that just storing the filename of the image would keep the db size low...

View 1 Replies

C# - Web Service Design - Error Code (store In Source Code Or Store In Database?

Jan 19, 2011

Web service error response (code/message etc) would you store it in a database? or would you keep the error response in a method.By the time I'm done with this, there will be hundreds of error response, maybe in the future, thousands? (I dont know yet, depends how large this web service grows).EDIT: error response is the response returned back to the application via the web service, (not to be confused with error logging).

View 1 Replies

SQL Server :: How To Store File Into Database/couldn't Store File Larger Than 4mb

Oct 22, 2010

Below is the code I use to store file into database but there are a few problems.

1. couldn't store file larger than 4mb

2. couldn't store doc,docx,xlsx but only .txt

my table column are:

[code]....

View 2 Replies

Store Date 4 Days Later Than Current Date And Then Store In Database

Jun 19, 2012

If I select the today date

Then I want store 4days later date in the database

View 1 Replies

Best Place To Put SQL In A App Is?

Feb 14, 2011

I am creating a ASP.NET application that is pretty much self contained, it will be pushed to different hosts and as a result will include an embedded database engine - I did look at SQLite but that can not run under medium trust and that could be an issue, so it looks like it is going to have to be Microsoft SQL Server Compact Edition 4.

Microsoft SQL Server Compact Edition does not support stored procedures and because of such I'm wondering where the best place to include the SQL code would be, taking into account future edits, etc.

So far I think that my options are either directly embedded in the code as a String or Stringbuilder type (which can get messy for advanced queries), or maybe in SQL files stored in the App_GlobalResources folder.

View 4 Replies

Web Forms :: Skins And Where To Place Them

Mar 4, 2010

I'm trying to figure out how to use skins, and I'm a bit baffled by one thing. When I place a skin file in the "root" of the theme I'm working on, it works great. However, if I try to make a folder to put it in, it fails. I cannot seem to locate any particular information that describes why this is. This is what works:

/App_Themes/App_Themes/MyTheme/App_Themes/MyTheme/MySkin.skin
This is what I'd prefer, but does not work
/App_Themes/App_Themes/MyTheme/App_Themes/MyTheme/skins/App_Themes/MyTheme/skins/MySkin.skin

View 2 Replies

Where To Place The Redirection Statement

Jul 4, 2010

Using the this article - [URL], where do I place my redirection statement?

Say for example, after a successful insertion of a new record I am going to redirect the page to success.aspx saying "A new record has been successfully added".

Where am I going to place my redirection statement?

Is it in this way

Code:

[code]....

View 7 Replies

Place Setting On Web.config?

Sep 21, 2010

we were all recently alerted by scottgu with this security vulnerability. [URL] I'm wondering, since I've been redirecting errors via Global.asax on the Application_Error event, I was wondering if that can suffice the fix for this issue or do I still need to place a setting on the web.config?

View 1 Replies

ADO.NET :: What Is Best To Use In VB NET In Place Of The VB6 Adodb.recordset

Dec 12, 2010

I gather from what I have read that the VB6 adodb.recordset is not the best way to work with database tables in VB NET

I have a program created in VB6 that I would like to upgrade or re-write in VB NET

What I am finding difficult to understand or find is the answer to what I use in place of the VB6 adodb.recordset

I have found the code to make DATASET and OleDbDataAdapter and can open an Access or SQL table

But what I do not find or follow is how you move through the rows of a table

With the adodb.recordset you could Do While Not EOF and MoveNext

What is the equivalent to that in VB NET without using adodb.recordset?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved