0

I have put following code on html page.

<td bgcolor="<%=TableHeaderColor%>">&nbsp;</td>

However it seems html understand above code and it renders colors. when I change letters in between <%= %> , I get different colors.

Can someone help me to understand this?

3
  • It allows you to write inline response from server Commented Oct 10, 2013 at 10:30
  • The ASP tags are interpreted by the webserver and translated to HTML before sending it to the user. Commented Oct 10, 2013 at 10:31
  • ok, then how do I get different colors when I edit them on destop without a webserver? Commented Oct 10, 2013 at 10:51

5 Answers 5

1

Html doesn't understand a thing, webserver does. Before the page is sent to the client, it's being translated every time and the client (web browser) sees only the generated html result.

Sign up to request clarification or add additional context in comments.

1 Comment

To prove this, have a look at the source once it's in your browser.
0

In page load : (Server side)

page-load ()

{
if(any condition )
{
TableHeaderColor="Red";
}
else if(any condition )
{
TableHeaderColor="Yellow";
}
else if(any condition )
{
TableHeaderColor="Green";
}


}

Now if you call this TableHeaderColor in your client side as your way , it's changing on your condition ,

It's just a key only

Comments

0

Try this :

<td style="background:<%=TableHeaderColor%>">&nbsp;</td>

Comments

0

All the asp.net tags you write will be translated once they pass the server. For example: when you use the tag <asp:hyperlink> it will be translated to <a href=""> try opening the source of a website written in asp, you won't see the asp tags but just html

Comments

0

Is not intepreted by HTML, but by server side page processing.

Ref:

With ASP, code was enclosed within <%... %> tags and page processing began with the first statement following the first <%> tag. With ASP.NET, any code that is to be processed as soon as the page is loaded must be included within the Page_Load intrinsic event. You can still write code in <%... %> blocks, but it will be executed at render time (in top-down fashion, as in ASP) after the page is loaded. If you need to execute initialization code, it should appear in the Page_Load event, which is raised immediately after the page is loaded by the ASP.NET engine

Link: http://msdn.microsoft.com/it-it/library/f0111sbh(v=vs.100).aspx

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.