S
Stephen Adam
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;
}
}
}
}
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;
}
}
}
}