Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need a global object in a web app
Message
 
To
09/05/2008 10:31:08
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01316004
Message ID:
01316087
Views:
16
>>I've got a web app with an Employee page which doubles as both "Add New" or "Edit" edit modes. In my Business Object (BO) I have an EmployeeRules.partial.cs where I have my own custom validation rules that I want to run differently depending on which edit mode I'm in. The web page will have the knowledge as to which edit mode I'm currently in.
>>
>>What global object exists in both places?
>>
>>No, the web Session object doesn't exist in the BO rules object.
>>
>>Nor does the appWeb object exist in the BO rules object.
>>
>>What object/class is available to me for communicating which edit mode I'm currently in so I can run a different set of validation rules?
>
>Does your BO use a dataset? If so you could just check the RowState.
>As a general rule, I dislike maintaining 'state' flags.

No, the BO has a dataset, but I'm not directly touching it. I'm calling the "Save" method from the web form and that in turn calls the validation/rules classes in the BO.

In particular I'm trying to avoid an unhandled error by the BO when the BO tries to insert a row into the SQL table where the primary key is duplicated. Thus, I want to see in the validation/rules section of my EmployeeRules.partial.cs class whether that particular primary key exists. But, I only want to do that on an "Add New" and not during an "Edit".

Again, from what I can tell the BO, which is a separate project in the solution has no visibility to cookies, hidden fields, the session object and things of that nature that live in a webpage.

In VFP we would have a global App object that was visible to everything and you could create properties like "EditMode" that you could use in subsequent code anywhere in the entire project.

But, in MM .NET there is an AppWeb (static) that is visible to the UI (web pages), but not in the BO where I need it.

Question, what other global objects exist in MM .NET that I can use to flag which edit mode I'm in to the validation/rules in my EmployeeRules.partial.cs code that lives in the BO?

Or is this a problem with MM .NET where the one of the design goals is to separate the Business logic from the presentation logic? Perhaps, the separation between the two is working too well.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform