ASPX and C# file on SharePoint Server

D

Drew Carter

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";
}
}
 
B

Bob Barrows [MVP]

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

I can't say about Sharepoint, but I'm certain it's not an ASP problem ...
perhaps ASP.Net.

There was no way for you to know it (except maybe by browsing through some
of the previous questions in this newsgroup before posting yours - always a
recommended practice) , but this is a classic asp newsgroup. ASP.Net bears
very little resemblance to classic ASP so, while you may be lucky enough to
find a dotnet-knowledgeable person here who can answer your question, you
can eliminate the luck factor by posting your question to a group where
those dotnet-knowledgeable people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top