'global' variables within ASP.NET page..

Pichi

New Member
In classic ASP variables initialised in the ASP script area were visible throughout the HTML within <% %> tags. How can I set a variable to be globally visible from the Page_Load area to be visible throughout the page.<BR><BR>eg. a Dim sString as String in the Page Load Sub is not visible when referenced to in the HTML within <% %><BR><BR>ThanksI believe it's: Dim Public myvar as stringbut i think that's kinda defeating the purpose of asp.net... i always read you want to seperate code and html as much as possible.. <BR><BR>put in a server side control and have your code behind populate it with the global variable's value... you can use <asp:literal id="dfld" runat="server" /> and this acts as a 'placeholder'.. then in your code behind.. just do dfld.text = globalvariable<BR><BR>The code speration is true. You can use the codebehind and webform objects to do anything you can imagine, but just keep it in the codebehind.
 
Back
Top