D
Dave
Hi all,
I am still fairly new to dot net, so go easy...
Anyway,
I have my main page. In this page is a usercontrol that
manages the security of the page.
I am authenticating a user against Content Management
Server, then checking locally if they have specific
rights to content on that page.
My class in the usercontrol is...
##########################################################
public class UserAuthenticationAndTracking :
System.Web.UI.UserControl
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["conn"]);
private bool UserApproved;
private void Page_Load(object sender,
System.EventArgs e)
{
// Put user code to initialize
the page here
DataSet DS = new DataSet();
if (!IsPostBack)
{
if
(CmsHttpContext.Current.User != null)
{
try
{
conn.Open
();
SqlCommand UserData = new SqlCommand("select *
from extranetUserDetails where UserApproved = 1 and
UserName = @UserName", conn);
UserData.Parameters.Add("@UserName",
SqlDbType.NVarChar).Value =
CmsHttpContext.Current.User.ToString();
SqlDataReader readData = UserData.ExecuteReader();
if
(readData.HasRows)
{
userApproved = true;
}
else
{
userApproved = false;
}
Trace.Warn
("Authenticated", UserApproved.ToString());
}
finally
{
conn.Close
();
}
}
}
}
public bool userApproved
{
get
{
return UserApproved;
}
set
{
UserApproved = value;
}
}
##########################################################
In my page, (.aspx) I want to see if the user is approved.
I am trying...
##########################################################
if
(UserAuthenticationAndTracking.userApproved)
{
txtUserName.Text
+= " USER APPROVED";
}
else
{
txtUserName.Text
+= " USER NOT APPROVED";
}
##########################################################
but when I compile, I am getting...
C:\Inetpub\wwwroot\MyCMSApp\Templates\nqt.aspx.cs(37): An
object reference is required for the nonstatic field,
method, or
property 'MyCMSApp.CMSUserControls.UserAuthenticationAndTr
acking.userApproved'
Am I missing something???
Previously, I had tried to just access a public variable
in the usercontrol, but that didn't work either.
Also, may be of assistance, when I type
UserAuthenticationAndTracking, I do not get the property
in the intellisense.
What I need to do is to make the userApproved status to
any other user controls and the page. I don't know if I
am going about it in the right way, so any assistance
will be very much appreciated.
Best regards,
David Colliver.
http://www.DerbyFOCUS.com
I am still fairly new to dot net, so go easy...
Anyway,
I have my main page. In this page is a usercontrol that
manages the security of the page.
I am authenticating a user against Content Management
Server, then checking locally if they have specific
rights to content on that page.
My class in the usercontrol is...
##########################################################
public class UserAuthenticationAndTracking :
System.Web.UI.UserControl
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.AppSettings["conn"]);
private bool UserApproved;
private void Page_Load(object sender,
System.EventArgs e)
{
// Put user code to initialize
the page here
DataSet DS = new DataSet();
if (!IsPostBack)
{
if
(CmsHttpContext.Current.User != null)
{
try
{
conn.Open
();
SqlCommand UserData = new SqlCommand("select *
from extranetUserDetails where UserApproved = 1 and
UserName = @UserName", conn);
UserData.Parameters.Add("@UserName",
SqlDbType.NVarChar).Value =
CmsHttpContext.Current.User.ToString();
SqlDataReader readData = UserData.ExecuteReader();
if
(readData.HasRows)
{
userApproved = true;
}
else
{
userApproved = false;
}
Trace.Warn
("Authenticated", UserApproved.ToString());
}
finally
{
conn.Close
();
}
}
}
}
public bool userApproved
{
get
{
return UserApproved;
}
set
{
UserApproved = value;
}
}
##########################################################
In my page, (.aspx) I want to see if the user is approved.
I am trying...
##########################################################
if
(UserAuthenticationAndTracking.userApproved)
{
txtUserName.Text
+= " USER APPROVED";
}
else
{
txtUserName.Text
+= " USER NOT APPROVED";
}
##########################################################
but when I compile, I am getting...
C:\Inetpub\wwwroot\MyCMSApp\Templates\nqt.aspx.cs(37): An
object reference is required for the nonstatic field,
method, or
property 'MyCMSApp.CMSUserControls.UserAuthenticationAndTr
acking.userApproved'
Am I missing something???
Previously, I had tried to just access a public variable
in the usercontrol, but that didn't work either.
Also, may be of assistance, when I type
UserAuthenticationAndTracking, I do not get the property
in the intellisense.
What I need to do is to make the userApproved status to
any other user controls and the page. I don't know if I
am going about it in the right way, so any assistance
will be very much appreciated.
Best regards,
David Colliver.
http://www.DerbyFOCUS.com