Access to variables in an asp.net user control vs an include file

Posted by user204588 on Stack Overflow See other posts from Stack Overflow or by user204588
Published on 2009-12-17T15:37:51Z Indexed on 2010/03/18 3:01 UTC
Read the original article Hit count: 371

I've asked this question before but couldn't get the answer I was looking for so I'm going to try it again.

I'm translating pages from old asp to asp.net and I don't want to do this any other way so I really just want to know if this can be done.

In asp, I'd assign a variable on one page

<% myVar = "something" %>

I could assign many variables here and then use an include

<!--#include file="Test2.aspx"-->

then in test2 file, I could access all the variables without having to pass all the variables into the control or declaring them again, like

<% myVar = "something else" %>

I want to do this the dot net way but I have some thirty variables on the page and i don't want to pass a bunch into the user control and I don't want to have to keep declaring the same variables.

All I really want to know is if there is some way to replicate the behavior above in asp.net?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about server-side-includes