473,320 Members | 1,940 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,320 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 2296
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.