"Neil B" <Ne***@discussions.microsoft.comwrote in message
news:89**********************************@microsof t.com...
I'm new to C# and VS 2008 Web App development. I can't find anything that
explains how variables and other information is shared between the C#
(behind)code and the HTML in the same page. I understand the the
<%=variable%is used in HTML but any variable that I define in the C#
code
gives an error that its not in the context.
How does C# and HTML share variables????
Basically, they don't. C# is running on the server and html in the
client. The memory spaces are different and no variable can be shared.
When you need to share some information between the server and the
client, you have to move it back and forth between both machines. One way to
move information is the one you mentioned: Writing <%=variable%in the
..aspx file will cause the server code to replace that text with the content
of the variable, which is then inserted into the html code which is in turn
sent to the browser. Therefore, the content of the variable will be "seen"
by the client code. Note: Mark the variabe as "public"; you will get an
error if it is "private".