ascx and sharepoint

Discussion in 'ASP .Net Web Controls' started by Drew Carter, Apr 19, 2007.

  1. Drew Carter

    Drew Carter Guest

    Hi. I'm not sure whether this is a SharePoint or an ASP problem... but I
    thought it made sense to post here.

    I'm having trouble instantiating a C# class from within my ascx file. When
    I attempt to run it on our SharePoint 2007 server, I receive this error in
    the log file: "System.Web.HttpCompileException: c:\Program Files\Common
    Files\Microsoft Shared\web server
    extensions\12\TEMPLATE\CONTROLTEMPLATES\ASPNETControl\ASPNETControl.ascx(12):
    error CS0103: The name 'Class1' does not exist in the current context"

    How do I allow the program to recogonize Class1? When I rewrite the aspx
    file to return an ordinarily string, it funcitons fine, as long as I don't
    call the outside class. Class1 was compiled correctly and it exists as
    bin\Class1.dll.

    Any advice would be appreciated, and I have my code below. Thanks!

    -Drew Carter



    GetUsername.ascx:

    <%@ Control Language="C#" AutoEventWireup="true" ClassName="GetUsername" %>

    <script runat ="server" >

    protected override void Render(HtmlTextWriter UI)

    {
    Class1 output = new Class1();
    UI.Write(output);

    }

    </script>





    Class1.cs

    using System;

    public class Class1
    {
    public Class1()
    {}
    public static string getUserName()
    {
    return "Class1 String";
    }
    }
    Drew Carter, Apr 19, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Quentin
    Replies:
    1
    Views:
    486
    Quentin
    Jul 29, 2003
  2. Jason Shohet
    Replies:
    1
    Views:
    482
    Kevin Spencer
    Nov 10, 2003
  3. Holger (David) Wagner
    Replies:
    2
    Views:
    1,940
    Holger (David) Wagner
    Jul 3, 2004
  4. Joe
    Replies:
    1
    Views:
    372
    Jeffrey Tan[MSFT]
    Feb 16, 2004
  5. Replies:
    2
    Views:
    536
Loading...

Share This Page