CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> .NET

 Problem with scope of DBUtility in page header

Print topic Send  topic

Author Message
commlinx

Posts: 2
Posted: 08/12/2008, 1:15 AM

I'm new to CCS and .NET development not having done much web development for five years or so. I've created a page header and would like to display the name of the currently logged in user on the header. I've looked at the examples / help and came up with the following code in the AfterInitialize event for the header page:

 protected void Page_AfterInitialize(object sender, EventArgs e) {  
  if (DBUtility.UserID != null)   
     UserLogin.SetValue(DBUtility.UserLogin);   
}  

However when trying to publish and run I get the following error / highlighted code line:

Compiler Error Message: CS0103: The name 'DBUtility' does not exist in the current context
if (DBUtility.UserID != null)

I looked at several examples and made sure that I was using all the same classes at the top of the ascx.cs file. Is there something different I should be doing to do this sort of thing in a page header?
View profile  Send private message
tsgroman


Posts: 64
Posted: 08/12/2008, 6:47 PM

The UserLogin is exposed through the Session("UserLogin") variable by default.

Drop a label on a page and add a 'Retrieve Value for Control' Action to the 'Before Show' server event.

Control Name = the name of the label
Source Type = Session
Source Name = UserLogin

The defaults can be changed via the Project -> Settings -> Security -> Advanced.
View profile  Send private message
commlinx

Posts: 2
Posted: 08/12/2008, 8:34 PM

Hi tsgroman, thanks very much for your reply. Originally I was keen to use my own code because I wanted to retrieve a few other pieces of information like a full name and access rights from the database, however realised I'm best to avoid this because among other things I was getting the designer in a state where it wouldn't keep the code up to date.

In this case what I can do is use some DLookup events for the other fields and just tried the following in the Criteria and it worked fine:

"[UserID] = " + ((Session["UserId"] == null) ? "-1" : Session["UserId"])

When I had a further look I also found a class called Utility under the InMotion security classes that provide some wrappers such as Utility.UserLogin, they also just retrieve the information from the session.
View profile  Send private message
dragoon


Posts: 173
Posted: 08/25/2008, 1:44 PM

commlinx, if you have too many fields that you want to retrieve you better make use of some custom code and grab all of them in one query, instead having a query for each 'property' of the logged user.

This in just an ideea ... on the other hand, having as much as possible bits of code in designer is easier...

Of course, it depends of the scale of the application you're trying to build...
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.