473,396 Members | 1,847 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,396 software developers and data experts.

String Builder

Hello,

I am creating a string using StringBuilder:

Dim code As New StringBuilder
code.Append("<script type=""text/javascript""><!--")
Response.Write(code.ToString)

However, I don't get any code when I do Response.Write.

I thinks it is because of "".

Could someone, please, help me out with this?

Thanks,

Miguel

Dec 17 '06 #1
4 2302
the quick answer is that you don't need double quotes for javascript - try
this:

Dim code As New StringBuilder
code.Append("<script type='text/javascript'><!--")
Response.Write(code.ToString)

"shapper" <md*****@gmail.comwrote in message
news:11**********************@16g2000cwy.googlegro ups.com...
Hello,

I am creating a string using StringBuilder:

Dim code As New StringBuilder
code.Append("<script type=""text/javascript""><!--")
Response.Write(code.ToString)

However, I don't get any code when I do Response.Write.

I thinks it is because of "".

Could someone, please, help me out with this?

Thanks,

Miguel

Dec 17 '06 #2


On 17 Dez., 21:38, "shapper" <mdmo...@gmail.comwrote:
Hello,

I am creating a string using StringBuilder:

Dim code As New StringBuilder
code.Append("<script type=""text/javascript""><!--")
Response.Write(code.ToString)

However, I don't get any code when I do Response.Write.

I thinks it is because of "".

Could someone, please, help me out with this?

Thanks,

Miguel
Hello,
why do you want to write the script.tag to the page? The double quotes
are not hte problem because you have masked them correctly.
The String IS written to the page but because its a javascript , its
not visible direclty. Look at the html-sourcecode and you will see it
at the top of the page.
A better way to register scripts on a page is the function
Page.RegisterClientScriptBlock to register a script which is executed
directly. Use this function for script-functions you want to calllater.
You cant access page-controls at this time because they are still
loading.
If you want to access page-controls use the .net-function
Page.RegisterStartupScript which will be executed when the page is
loaded.

Regards,
Tim

Dec 17 '06 #3
Hi,

I know about RegisterClientScriptBlock. The problem is that I am
creating a control thats ads a Google AdSense ad to the page.

So, if I am not wrong, I need to add the code exactly to the place on
my page where I want the add to be.

For this reason by custom control includes a literal where text is
equal to Google AdSense code which can be as follows:

<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "image";
google_ad_channel = "";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Anyway, is this the right way to do this?

Any sugestion will be welcome.

Thanks,
Miguel
TiSch wrote:
On 17 Dez., 21:38, "shapper" <mdmo...@gmail.comwrote:
Hello,

I am creating a string using StringBuilder:

Dim code As New StringBuilder
code.Append("<script type=""text/javascript""><!--")
Response.Write(code.ToString)

However, I don't get any code when I do Response.Write.

I thinks it is because of "".

Could someone, please, help me out with this?

Thanks,

Miguel

Hello,
why do you want to write the script.tag to the page? The double quotes
are not hte problem because you have masked them correctly.
The String IS written to the page but because its a javascript , its
not visible direclty. Look at the html-sourcecode and you will see it
at the top of the page.
A better way to register scripts on a page is the function
Page.RegisterClientScriptBlock to register a script which is executed
directly. Use this function for script-functions you want to calllater.
You cant access page-controls at this time because they are still
loading.
If you want to access page-controls use the .net-function
Page.RegisterStartupScript which will be executed when the page is
loaded.

Regards,
Tim
Dec 17 '06 #4


On 17 Dez., 23:21, "shapper" <mdmo...@gmail.comwrote:
Hi,

I know about RegisterClientScriptBlock. The problem is that I am
creating a control thats ads a Google AdSense ad to the page.

So, if I am not wrong, I need to add the code exactly to the place on
my page where I want the add to be.

For this reason by custom control includes a literal where text is
equal to Google AdSense code which can be as follows:

<script type="text/javascript"><!--
google_ad_client = "pub-xxxxxxxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "image";
google_ad_channel = "";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

Anyway, is this the right way to do this?

Any sugestion will be welcome.

Thanks,
Miguel

TiSch wrote:
On 17 Dez., 21:38, "shapper" <mdmo...@gmail.comwrote:
Hello,
I am creating a string using StringBuilder:
Dim code As New StringBuilder
code.Append("<script type=""text/javascript""><!--")
Response.Write(code.ToString)
However, I don't get any code when I do Response.Write.
I thinks it is because of "".
Could someone, please, help me out with this?
Thanks,
Miguel
Hello,
why do you want to write the script.tag to the page? The double quotes
are not hte problem because you have masked them correctly.
The String IS written to the page but because its a javascript , its
not visible direclty. Look at the html-sourcecode and you will see it
at the top of the page.
A better way to register scripts on a page is the function
Page.RegisterClientScriptBlock to register a script which is executed
directly. Use this function for script-functions you want to calllater.
You cant access page-controls at this time because they are still
loading.
If you want to access page-controls use the .net-function
Page.RegisterStartupScript which will be executed when the page is
loaded.
Regards,
Tim
Hi,
im not familiar with google adsense but you can add the script where
ever you want for exaple:

Dim script As String = vbCrLf & _
"<script type=""text/javascript""
language=""JavaScript""
src=""http://pagead2.googlesyndication.com/pagead/show_ads.js>" &
vbCrLf & _
" google_ad_client = ""pub-xxxxxxxxxxxxxxxx"";" &
vbCrLf & _
" google_ad_width = 728;" & vbCrLf & _
" google_ad_height = 90;" & vbCrLf & _
" google_ad_format = ""728x90_as"";" & vbCrLf & _
" google_ad_type = ""image"";" & vbCrLf & _
" google_ad_channel = """";" & vbCrLf & _
"</script>"

Me.PlaceHolder1.Controls.Add(New LiteralControl(script))

Ragards,
Tim

Dec 17 '06 #5

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

Similar topics

11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
2
by: José Joye | last post by:
Hello, I was wondering if there is a method that exists to replace multi-spaces within a string with single-space. eg: "12 3 4 56" --> "12 3 4 56" I think this could be done by...
33
by: genc_ymeri | last post by:
Hi over there, Propably this subject is discussed over and over several times. I did google it too but I was a little bit surprised what I read on internet when it comes 'when to use what'. Most...
9
by: Mantorok | last post by:
Hi all I have a plain text string, sometimes the string will contain special characters, how can I encode this string in xml format? Thanks Kev
4
by: James Page | last post by:
Hi all I have a shopping cart object which I'd like to send the contents via an e-mail. I get an error saying 'hybridDictionary' cannot be converted to string. Does anyone know how to do...
4
by: shapper | last post by:
Hello, How can I transform a Generic List(Of String) to a string as follows: "value1,value2,value3,value4, ..." Thanks, Miguel
7
by: simonZ | last post by:
I have array variable transfer: String transfer which has some data Than I would like to convert this data into string: Which way is more efficient: StringBuilder rezult=new StringBuilder(); ...
29
by: ApeX | last post by:
Hi guys, i hace a question i have a datagrid col1 col2 ----------------- D text0 text1 text2 D text3
5
by: TazaTek | last post by:
Hello, I've seen some vague references on how to do this a factory, but not in enough detail to create one, or even know if it's what I need. Essentially, I'll have one of about 5 classes that...
13
by: xzzy | last post by:
None of the following properly do the VB.net double quote conversion because all of the following in csharp convert to \" instead of just a double quote: " I have tried: char...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.