Results 1 to 3 of 3

Thread: What am I doing wrong?

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    What am I doing wrong?

    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
    Code:
    <%@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
    Code:
    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

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: What am I doing wrong?

    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.
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    Resolved Re: What am I doing wrong?[Resolved]

    I was able to solve this:
    Here is what I did. Create a file called CommonCode.cs
    Code:
    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:

    Code:
    CommonCode cc = new CommonCode();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width