Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASPX and C# file on SharePoint Server

Thread Tools

ASPX and C# file on SharePoint Server

Drew Carter
Posts: n/a
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\ASPNETCont rol\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

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

-Drew Carter


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

<script runat ="server" >

protected override void Render(HtmlTextWriter UI)

Class1 output = new Class1();




using System;

public class Class1
public Class1()
public static string getUserName()
return "Class1 String";

Reply With Quote
Bob Barrows [MVP]
Posts: n/a
Drew Carter wrote:
> 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 MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MCTS Sharepoint Server or Windows Sharepoint Services RajivI MCTS 2 10-06-2007 12:13 PM
certification in Biztalk Server 2006 / Sharepoint server? =?Utf-8?B?Tml0eWE=?= Microsoft Certification 0 08-02-2007 08:56 AM
Using Windows Auth in Sharepoint and ASPx pages question rote ASP .Net Security 3 05-07-2007 03:53 AM
How to change aspx files in a SharePoint web site? keithb ASP General 0 02-08-2006 09:23 PM
SharePoint WebParts in ASPX Web App George Durzi ASP .Net 0 11-14-2003 06:33 PM