This is a migrated thread and some comments may be shown as answers.

<% %> Syntax *grml*

1 Answer 49 Views
Getting started with ASP.NET
This is a migrated thread and some comments may be shown as answers.
Wolfgang Kamir
Top achievements
Rank 1
Wolfgang Kamir asked on 17 Jul 2006, 06:28 PM
Hi all!

This may be the most basic question there is, but as i cannot google it or search it with any other search-function (not even in my MSDN Library) i have to ask it anyway...

What exactly means

<%= MyRadControl.ClientID %>
and
<%# MyRadControl.ClientID %>
and
<% MyRadControl.ComeGetSome() %>   ?

actually it's pretty clear to me that it is some kind of pre-response makro stuff (by ASP.NET), but i can't see the difference (sometimes in die radcontrols documentation <%= %> is used and sometimes <%# %> is used. What's the difference?

It is hard to google it or find it otherwise just because it's only special characters and this is filtered out by the searchengines i tried to use...

Best regards,
Wolfgang

1 Answer, 1 is accepted

Sort by
0
Wolfgang Kamir
Top achievements
Rank 1
answered on 18 Jul 2006, 07:11 AM

Nevermind, found out already ;)

If someone else is asking himself the same thing and has troubles to look it up:

<% %> is the normal Syntax for server-side script (processed before the page is rendered to the client).

So something like <% Response.Output.Write("<b>Hello</b>"); %> will just write the bold 'Hello' Text to the response instead of the original statement.

<%= %> is an abbreviation for the upper statement, i.e. <%="<b>Hello</b>" %> would just write the same text to the response...
<%=myServersideObject.ClientID%> would write the ClientID of the object to the repsonse (given the fact, that the property 'ClientID' is a string).

At last <%# %> is DataBinding-Syntax (therefore one has to do DataBind()) somewhere on the page when using r.a.d.window...

Maybe this helps someone else who is new to ASP.NET too! Everyone else will know this anyway i guess ;-)

Kind regards,
Wolfgang

Tags
Getting started with ASP.NET
Asked by
Wolfgang Kamir
Top achievements
Rank 1
Answers by
Wolfgang Kamir
Top achievements
Rank 1
Share this question
or