Re: Code-Behind variables

From: Scott M. (s-mar_at_BADSPAMsnet.net)
Date: 03/06/04


Date: Sat, 6 Mar 2004 12:16:28 -0500


> Notice that it is using Response.Write calls, which generates HTML.

Well no, more accurately it simply sends TEXT to the browser (note: it may
be any value from any data-type, but it gets sent to the client as text).
The text could be anything at all (HTML, JavaScript, VBScript, XML, etc.).
The "Write" method of the "Response" object doesn't care what text you write
and it doesn't "generate" anything. It just sends what you tell it to.

> The tags <%= and %> are actually just a shortcut for Response.Write the
code inside.

More accurately, just the "=" used as a prefix for some expression that
results in a value that can be sent to the browser is a shortcut for
Response.Write. And, you could only use that shortcut when the script block
was only going to contain that one command (ie. <% ="Hello World" %>).

The <% and the %> are actually shorthand for <SCRIPT> and </SCRIPT>. They
are the way to indicate a server side script block.

> Viewstate is used by the server, and is not available for use on the
> client. Modifying it's value will result in errors on the server. The
> values in Viewstate are Base64 encoded, which means although it
> "could" be read, it's not very easy - to put it mildly.

It is very easy to add and read items to/from ViewState in the CodeBehind
using ViewState.Add(key, value) and ViewState.Item(key). The stored and
then read value can then be use in any way that you want to, including
sending down to the client.

> Look at <input> type=hidden> tags. If you add the runat="server" property,
you get a
> .NET object to code against, but you will have to use it's Attributes
> collection rather than just setting it's Value property.

Um no. If you have marked the hidden form field as runat=server, you can
code against its .value property directly from the codebehind.

You've given several mistaken or misleading pieces of advice and/or facts
here. I suggest you read up on this or try it out before commenting.



Relevant Pages

  • Re: How do I get HTML sent to server?
    ... are trying our best to approximate and document the client view. ... anyone can but browser cannot. ... mechanics of this particular browser applied to the server HTML ...
    (comp.lang.javascript)
  • Re: Which is more secure Outlook or Hotmail?
    ... How do you know it's untrusted and HTML without opening the message? ... Just discard the HTML and let the client display the ... Can you switch to a text-only view in your browser too? ... If a hosted service ever gets compromised that might be helpful.-) ...
    (microsoft.public.security)
  • Re: Div section does not dispaly
    ... You told the browser to make P2 visible by using JavaScript: ... But the browser is never even receiving the P2 html because of the Visible attribute in the server declaration: ... As Marina stated, you can have it only one way or the other. ... that div won't even exist in the HTML on the client. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: FAQ: How do I make a pop-up menu in HTML?
    ... > CGI.pm predates pop-up browser windows. ... As the HTML specification rightly points out: ... Or to put it another way: it's entirely the business of the client ... But whichever source of documentation you choose for the CGI.pm ...
    (comp.lang.perl.misc)
  • RE: ASP.NET Call Class Function
    ... BUT it'll still run on the SERVER not the CLIENT. ... > FUNCTION write in the codebehind? ... > Example in the HTML ... > sub mySub ...
    (microsoft.public.dotnet.framework.aspnet)

Loading