By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,442 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Trace.Warn not working in my class

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
"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.