Code in HTML

  • Thread starter Thread starter Joe via DotNetMonster.com
  • Start date Start date
J

Joe via DotNetMonster.com

Hi,

Within the HTML if I try to put an if statement, I get an error:
BC30201: Expression expected

This is a simplified example:

<%# If StoreNumber = "1" Then %>

<b>Store1</b>

<%# EndIf %>

Thanks
 
Use <% for code. <%# is for databidning.

As a side note this is a bit old style. I would recommend doing this in code
behing rather than mixing code and HTML as in the pre ASP.NET days...

Patrice
 
Patrice said:
Use <% for code. <%# is for databidning.

As a side note this is a bit old style. I would recommend doing this in code
behing rather than mixing code and HTML as in the pre ASP.NET days...

how do you control where the outputted html will show up on the aspx page if
you do this in your code behind? if, for instance, i have a search form and
a search button that executes some sql statements, and all this is handled
in the code behind, how would i go about response.writing the search results
to the bottom of the search page?
 
use a server control and write to that.
a label is rendered as a <span> tag I think, maybe a <div>, but either way,
that is one way to control where the output goes...
 
Steve said:
use a server control and write to that.
a label is rendered as a <span> tag I think, maybe a <div>, but either way,
that is one way to control where the output goes...
thanks


Dica said:
in
code

how do you control where the outputted html will show up on the aspx
page
 
Another way is to use the Literal control. It doesn't put any HTML tags
automatically - you can use it to inject HTML (or text or whatever) directly
into a specific location on your page.

HTH
 
A LiteralControl holds ViewState?


A LiteralControl inherits System.Web.UI.Control, which means that it HAS
ViewState, but a LiteralControl doesn't HOLD ViewState. Note that the
ViewState property is protected.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Aha! Thanks for the clarification.

--

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Back
Top