471,349 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 software developers and data experts.

HTML and C#

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????

Is there any good discussions on their relationship?

Thanks,
Neil
Jun 27 '08 #1
4 977
"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".
Jun 27 '08 #2
On May 19, 8:14*am, Neil B <Ne...@discussions.microsoft.comwrote:
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. *
post your code,
also remember that a var is by default private, if you want to be able
to use it in the aspx page you have to declare it as protected.
>
How does C# and HTML share variables????

Is there any good discussions on their relationship?
there is a aspnet NG
Thanks,
Neil
Jun 27 '08 #3
Neil,

As others all stated the code behind is running at the server, which is in
fact the IIS part (Internet Information Server).

As the ASPX page is rendered by that, then it changes the ASPX page in an
HTML page inserting JavaScript confirm the by you created DLL (in this case
with C#). The same happens when the page is send back (Don't think in C#
because that is only the program language that has created the DLL it can be
in the same case VB or/and any other program language that has the ability
to create a Net application)

Cor
"Neil B" <Ne***@discussions.microsoft.comschreef in bericht
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????

Is there any good discussions on their relationship?

Thanks,
Neil
Jun 27 '08 #4
The problem was that you have to specifically mark each of the variables as
public (I didn't try protected). They don't inherit this property from the
partial class (which is public).

Thank for all your help.
Regards, Neil

"Neil B" wrote:
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????

Is there any good discussions on their relationship?

Thanks,
Neil
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by cirillo_curiosone | last post: by
reply views Thread by Boris Ammerlaan | last post: by
9 posts views Thread by Patient Guy | last post: by
5 posts views Thread by serge calderara | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.