473,387 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to show variable on webpage?

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

Jan 14 '06 #1
5 2045
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
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"brett" wrote:
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

Jan 14 '06 #2
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

Jan 14 '06 #3
You have to be specific about what you really want to do. It looks now like
what you are saying is "I want to embed some client side script in my page".

For that, you can use the Page.RegisterClientScriptBlock method:

http://msdn.microsoft.com/library/de...BlockTopic.asp

Cheers.
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"brett" wrote:
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

Jan 15 '06 #4
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

Jan 15 '06 #5
It doesn't make any difference.
If you have any more questions just post it
Patrick

"brett" <ac*****@cygen.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
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

Jan 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Eep˛ | last post by:
I am trying to get a webpage to show its results (a single line) in an image's "alt" tag. Here's my code: <img src=medal.gif height=16 width=16 align=absmiddle alt="<?...
0
by: Mustafa Haider | last post by:
HI, I have created a report in Crystal Reports 8.5 and want to display it on my clients webpage. I will develop this webpage in ASP v3 so plz give me the code with which to show this report of...
18
by: Michael Skind | last post by:
Hello, I use a simple Table : <TABLE> <TR 1> <TD></TD> </TR> <TR 2> <TD></TD> </TR>
3
by: hendedav | last post by:
Hi gang. As with any other post, I am working on a project and have gotten stuck. I am trying to obtain a variable value in the parent webpage from an <iframe>. For instance: Parent Page code...
3
by: Tarren | last post by:
Hi: In Visual Basic is there the equivalent of a Session variable where I can store variables in memory while the executable is running? I have been coding ASP .NET for some time, but am new to...
2
by: Stefan Reinmers | last post by:
hi there, i include in a webpage (with the object tag) a dll to show in the webpage a windowsform (windowscontrollib.dll) when i test all on the development pc (winxp ,framework 1.1) it works fine....
5
by: rockdale | last post by:
Hi, all: I have a linkbutton and I use javascript to open another webpage in a new window. I also want to set my session variable value when this linkbutton get clicked. These session variable...
11
by: Adam Sandler | last post by:
Hello, I'd like to do a slide show in VB. I have one in JavaScript but the one in JavaScript always counts on the images to be in a given directory. This doesn't have to be fancy... something...
11
by: Tomek Toczyski | last post by:
I have an url of a webpage. I would like to load the content of the webpage to a variable. Sth like this: variable = loadwebpage( url ) How to do it? (I have just spent more than an hour...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.