Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Server.Execute: How to transmit variables between VB and C#

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi.

I've got two scripts

test1.aspx
Code:
<%@ Page Language="VB" %>
<%
	Dim myVar As String
	myVar = "Hello!"

	Server.Execute("test2.aspx")

%>

test2.aspx
Code:
<script language="C#" runat="server">

	void Page_Load(Object Src, EventArgs E) 		
	{
		myPage.Text = myVar;
	}

</script>
<asp:literal id="myPage" runat="server"/>

But it doesn't work. How can I transmit myVar value from 'test1.aspx' to
'test2.aspx'?

Thank you very much.
 
try this
Code:
<%@ Page Language="VB" %>
<%
    Dim myVar As String
    myVar = "Hello!"
    HttpContext.Current.Item("myVar") = myVar

    Server.Execute("test2.aspx")

%>

<script language="C#" runat="server">

    void Page_Load(Object Src, EventArgs E)         
    {
        string myVar ="";
        if(!(HttpContext.Current["myVar"] == null)){
           myVar = (string)HttpContext.Current["myVar"];
        }
        myPage.Text = myVar;
    }

</script>
<asp:literal id="myPage" runat="server"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top