PDA

Click to See Complete Forum and Search --> : What am I doing wrong?


Sansari71
Jan 12th, 2005, 11:18 AM
I am developing a web application in ASP.Net. I have some functions that are common so I decided to create a commoncode.cs file. At first I tried to add this file using
<%@page src="commoncode.cs" inherits="Commoncode" %>

It didn't work as any function that I was calling form this file was not recognized. I did some research on this web site and decided to create a dll and saved that dll in the bin folder. I then added a reference to this dll to the web application and added this line
using Commoncode;
whereever I needed this file. When I tried to build it, I am now getting this error:
A using namespace directive can only be applied to namespaces; 'Commoncode' is a class not a namespace

Can someone tell me what I am doing wrong? I am using C#. Thanks

Magiaus
Jan 12th, 2005, 03:39 PM
What are you building this app with?

the best thing to do if you have a commn method you want to use over and over is make it static.

Please show common code file please.

Sansari71
Jan 12th, 2005, 05:16 PM
I was able to solve this:
Here is what I did. Create a file called CommonCode.cs
using System;
using System.Web.UI;

public class CommonCode : System.Web.UI.Page
{
//create all the functions here
}

Then whereever I needed any of the functions I use the following syntax in the aspx.cs file:

CommonCode cc = new CommonCode();