How to show variable on webpage?

B

brett

I'd like to display a string variable on a webpage depending if the URL
has "localhost" in it or not. The string variable will have line
breaks and this text:
<script type="text/javascript" language="javascript">

How do I go about accomplishing this?

Thanks,
Brett
 
G

Guest

Using a placeholder on the page, and a LiteralControl to hold your "text":

if(Request.Url.IndexOf("localhost") !=-1)
{

myPlaceHolder.Controls.Add(new LiteralControl("yourtexthere"));

}

--Peter
 
B

brett

That doesn't allow me to put a string such as

<!-- Start of StatCounter Code -->
var sc_project=116000;
var sc_invisible=1;

Why doesn't the c# @ for literals work in ASP.NET?

Thanks,
Brett
 
B

brett

Yes - that is what I want to do. I have the code running fine but I
never see the javascript in the webpage. I'm using code behind rather
than c# script tags. Does that make a difference? I'm doing
everything on Page_Load() in the CS file.

Thanks,
Brett
 
P

Patrick.O.Ige

It doesn't make any difference.
If you have any more questions just post it
Patrick
 

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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top