473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 1032
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
1
by: cirillo_curiosone | last post by:
Hi, i'm new to javascript. I started studing it on the web few weeks ago, but still haven't been able to solve one big problem: HOT TO PASS VALUES FROM A SCRIPT VARIABLE TO A CHILD HTML...
33
by: LRW | last post by:
http://gto.ie-studios.net/index.php When you view the above site in IE, if the 1st of the three product images is tall enough to push the cell down a couple of pixels, IE somehow doesn't show...
0
by: Boris Ammerlaan | last post by:
This notice is posted about every week. I'll endeavor to use the same subject line so that those of you who have seen it can kill-file the subject; additionally, Supersedes: headers are used to...
9
by: Patient Guy | last post by:
Taking the BODY element as an example, all of its style attributes ('alink', 'vlink', 'background', 'text', etc.) are deprecated in HTML 4.01, a fact noted in the DOM Level 2 HTML specification. ...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
6
by: Guy Macon | last post by:
cwdjrxyz wrote: HTML 5 has solved the above probem. See the following web page: HTML 5, one vocabulary, two serializations http://www.w3.org/QA/2008/01/html5-is-html-and-xml.html
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.