468,550 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,550 developers. It's quick & easy.

Trace.Warn not working in my class

I have a page with Trace.Warns statements in my Page_Load and functions that
it calls, but it doesn't seem to work in a class that is defined on the same
page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = "
+ dBalance);
************************************************** ************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = " +
dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
**************************************************
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************** ***

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom
Sep 27 '07 #1
2 2354
Does the class you have inherit from the page object?

You can always use HttpContext.Current.Trace.Warn, which is the real method
call and not the shortcut that pages derived from the System.Web.UI.Page
provide.
--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"tshad" <tf*@dslextreme.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I have a page with Trace.Warns statements in my Page_Load and functions
that it calls, but it doesn't seem to work in a class that is defined on
the same page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance =
" + dBalance);
************************************************** ************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = " +
dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
**************************************************
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************** ***

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom

Sep 27 '07 #2
"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:ed**************@TK2MSFTNGP03.phx.gbl...
Does the class you have inherit from the page object?

You can always use HttpContext.Current.Trace.Warn, which is the real
method call and not the shortcut that pages derived from the
System.Web.UI.Page provide.
That was it.

I thought like all my other code when I don't use code-behind (Dreamweaver),
I can access functions such as Trace. I normally don't have to explicitly
define HttpContect.Current in my pages.

Thanks,

Tom
>

--
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"tshad" <tf*@dslextreme.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I have a page with Trace.Warns statements in my Page_Load and functions
that it calls, but it doesn't seem to work in a class that is defined on
the same page. I am writing this in C#

I am getting the following error at the 1st Trace.Warn:

***********************************************
Compiler Error Message: CS0118: 'System.Web.UI.Page.Trace' denotes a
'property' where a 'class' was expected

Source Error:

Line 84: {
Line 85: decimal mTemp = (decimal)dAmount;
Line 86: Trace.Warn("before rounding mTemp = ");
Line 87: mTemp = Decimal.Round(mTemp,2);
Line 88: Trace.Warn("after rounding mTemp = " + mTemp + " dBalance =
" + dBalance);
************************************************* *************************

The Function is:
*************************************
// Deposit - any positive deposit is allowed
public void Deposit(double dAmount)
{
if (dAmount 0.0)
{
decimal mTemp = (decimal)dAmount;
Trace.Warn("before rounding mTemp = ");
mTemp = Decimal.Round(mTemp,2);
Trace.Warn("after rounding mTemp = " + mTemp + " dBalance = "
+ dBalance);
dBalance += (double)mTemp;
}
}
****************************************

But in my function (not part of the class other than the Page class) the
Trace works fine:
************************************************* *
void OpenBankAccount()
{
// open a bank account
Trace.Warn("Create a bank account object");
BankAccount ba = new BankAccount();
ba.InitBankAccount();
************************************************* ****

Why wouldn't it work in a class defined on the same page?

Thanks,

Tom


Sep 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jens Alenius | last post: by
2 posts views Thread by Richard | last post: by
reply views Thread by Sally | last post: by
5 posts views Thread by martin | last post: by
reply views Thread by Elmo Watson | last post: by
13 posts views Thread by TJS | last post: by
2 posts views Thread by tshad | last post: by
2 posts views Thread by TiŽsto | last post: by
reply views Thread by Mark | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.