473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Calling a utility function from a web page

I added a C# utility class to my project. Now I would like to call that
class from a web page, but I'm not sure how to do it.

This is the new class:
public class autility : System.ComponentModel.Component
{
....
public bool Write_Log(System.Web.UI.Page Page, string strSessionLogText)
{
....

Calling code:
Write_Log (Page, "Message");

I receive the error:
The name 'Write_Log' does not exist in the class or namespace 'Project.Page'

How can I reference the function correctly?

Thanks!
Nov 19 '05 #1
1 1064
Jordan wrote:
I added a C# utility class to my project. Now I would like to call that
class from a web page, but I'm not sure how to do it.

This is the new class:
public class autility : System.ComponentModel.Component
{
...
public bool Write_Log(System.Web.UI.Page Page, string strSessionLogText)
{
...

Calling code:
Write_Log (Page, "Message");

I receive the error:
The name 'Write_Log' does not exist in the class or namespace 'Project.Page'

How can I reference the function correctly?

Thanks!


To call a method in a class as you defined it, you must create an
instance of that class and then call the method on it:

autility au = new autility();
au.Write_Log(Page,"message");

Now if you had defined it as a static method, you could have just done

autility.Write_Log(Page,"message");

but marking a method as static is not done for reducing lines of code.
There are good reasons for doing so (or not).

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
1
by: Klaus Vestergaard Kragelund | last post by:
Hi there I cannot seem to get this to work. In LabWindows I want to be able to call the Sleep function. But when I #Include "Windows.h" I get errors that it cannot build: "Redeclearation of...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
5
by: Diffident | last post by:
Hello All, I have written a webform which is by default derived from "Page" class. I have coded another utility class with few methods and an object of this class is instantiated from the webfom...
4
by: hansiman | last post by:
isn't it possible to call a public shared function that resides in another file directly from the datagrid html code?: <asp:TemplateColumn HeaderText="Password"> <ItemTemplate> <asp:Label...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
7
by: Spoon | last post by:
Hello, Consider the following code: int foo(int n) { return n+2; } class bar { public: int x;
5
by: Kurt Jakobsen | last post by:
Hello, I have a utility class that do some db queries that are used by independent pages. From one of the utility functions I would like to return variables back to the aspx page. In old C this...
4
by: raghuvendra | last post by:
Hi I have a jsp page with 4 columns: namely Category name , Category order, Input field and a submit button. All these are aligned in a row. And Each Category Name has its corresponding Category...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.