PC Review


Reply
Thread Tools Rate Thread

Class not visable - problem when not using visual studio

 
 
Stephen Adam
Guest
Posts: n/a
 
      9th Jan 2005
Hi there,

I've just started a c# project at work where I cannot use Visual Studio. I
am trying to pass variables from one form to another. When I try to create
an instance of the sending class in the receiving class I get a "The type or
namespace name 'XXXX' could not be found (are you missing a using directive
or an assembly reference?)" Error.

It seems that even though the sending class resides in the same folder as
the receiving class it still cannot be seen. I think it may have something
to do with the lack of a csproj file telling the compiler where the classes
are, though I have even tried editing a cjproj file and using it. IT might
also be because I'm not compiling my classes first, instead I'm just giving
an SRC and doing it on the fly (<%@ Page language="C#"
Src="/testbed/Send.cs" ).

I have included all the code to show what my problem is, can anyone help?
Would be very grateful



SEND.ASPX
<%@ Page language="C#" Src="/testbed/Send.cs" Inherits="Test.Send" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<body>
<form id="frmOne" action="Send.aspx" method="post" runat="server">

<asp:Button id="btnSend" runat="server" text="Send"> </asp:Button>

</form>
</body>
</html>

SEND.CS
namespace Test {

using System;
using System.Data;
using System.Data.SqlClient;

using System.Web;
using System.Web.UI;

using System.Web.UI.WebControls;


public class Send : System.Web.UI.Page {

protected System.Web.UI.WebControls.Button btnSend;

protected string StringToSend; // Add / Edit / Delete

protected override void OnInit(EventArgs e){
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent(){
this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
this.Load += new System.EventHandler(this.Page_Load);
}

protected void Page_Load(Object sender, EventArgs e) {
}

private void btnSend_Click(object sender, System.EventArgs e){
StringToSend = "Sent Text";
Server.Transfer("Receive.aspx");
}


// Getters for passing form vars
public string GetStringToSend(){
return StringToSend;
}
}

}


RECEIVE.ASPX

<%@ Page language="C#" Src="/testbed/Receive.cs" Inherits="Test.Receive" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<body>
<form id="frmOne" action="Receive.aspx" method="post" runat="server">
<table>
<asp:Lable runat="server" id="lblTest"> </asp:Lable>
</table>
</form>

RECEIVE.CS
namespace Test {

using System;
using System.Data;
using System.Web.UI.WebControls;


public class Receive : System.Web.UI.Page {

protected System.Web.UI.WebControls.Label lblTest;

protected string ReceivedString;


protected override void OnInit(EventArgs e){
InitializeComponent();
base.OnInit(e);
}

private void InitializeComponent(){
}

protected void Page_Load(Object sender, EventArgs e) {
if (!IsPostBack){

//Create Reference To NewsSectionSelect Page and Get Values
Send frmSend = (Send) Context.Handler;

ReceivedString = frmSend.GetStringToSend();

lblTest.Text = ReceivedString;
}

}
}
}



 
Reply With Quote
 
 
 
 
Stefan
Guest
Posts: n/a
 
      10th Jan 2005
Hi,

I beleive your problem is the lack of namespace references in
RECIEVE.CS.

Try adding:

using System.Web;
using System.Web.UI;

You are makeing reference to them in SEND.CS but not RECIEVE.CS.


Happy Coding,

Stefan
C# GURU
www.DotNETovation.com

"You always have to look beyond the horizon and can never be complacent
-- God forbid we become complacent."

Jozef Straus

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Cannot add a new class in Visual Studio steve907 Microsoft VB .NET 5 20th Feb 2008 03:50 PM
Problem with Marshal class in Visual Studio 2005 william.thorpe.b@bayer.com Microsoft C# .NET 7 11th Sep 2007 08:48 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft Dot NET 4 17th May 2007 07:56 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft Dot NET Framework 1 14th May 2007 08:05 PM
How to take an IE rendered screenshot of a website with visual studio .net 2002 or visual stuido .net 2003? I can't install visual studio .net 2005 on this computer. Daniel Microsoft C# .NET 0 14th May 2007 07:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:20 AM.