Can I Put Generic HTML Text in a Placeholder?

  • Thread starter Thread starter Ed West
  • Start date Start date
E

Ed West

Hello

Can I put generic HTML Text in a Placeholder, or does it need to be a
server control? If I can't, how can I put dynamically put in some text
in a template? ie, in the .ascx file


<html>
<title><!-- want to put something dynamic here!
</title>
<body>
blahblahblah ...
The current logged on user is: <!-- MORE DYNAMIC TEXT HERE -->
.. etc .


?

thanks,

-ed
 
Two way to do that:

First, you can replace them with server side scripts e.g.: <%=
WebForm1.myvalue %>

Second, you can place <asp:Literal> or <asp:Placeholder>control depending on
your need.
I'm sure both method can use HTML code as their value.
 
Hi Ed,

At runtime, all HTML in the Page Template is parsed into LiteralControls, as
ASP.Net is purely object-oriented. Therefore, you can certainly create a
LiteralControl, put HTML text into it, and add it to the Controls Collection
of any Control.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Thanks for the info... is there a way to populate a <%= someVar %> other
than making it a public property? ie, i have in my aspx page

<% title %>

and in the aspx.cs it

public String Title {
get { return _htmlTitle; }
set { _htmlTitle = value; }
}

is there a way to set many of vars like this from a function or something?
ie,

..aspx page:
<%=first_name%> <%=last_name%> <BR>
<%address%>
etc. etc. etc.

does each of those vars need to be a property in the aspx.cs page?


thanks

-dan
 
You could try "protected" rather than "public" but still noet getting you
far, have you tried an <asp:literal ? you can set html for that :)
 
Back
Top