472,958 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 1021
"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
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.