Can I Put Generic HTML Text in a Placeholder?

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
 
L

Lau Lei Cheong

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.
 
K

Kevin Spencer

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.
 
E

Ed West

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
 
M

Mark Harris

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top