Create String

S

shapper

Hello,

I need to create the following string at runtime to add to my page:

"
<script type="text/javascript"><!--
client = "3894758346587";
width = 800;
height = 600;
format = "image";
FirstWord; SecondWord
name = "1213131+6456456";
//-->
</script>
"

The values client, width, height, format, FirstWord, SecondWord, name
are taken from properties with the same name: Me.Client, Me.Width, ...

What is the best way to build this string.

Note that if, for example, Me.Client is empty then the code line
'client="3894758346587";' should not be added.

Thanks,
Thanks
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

shapper said:
Hello,

I need to create the following string at runtime to add to my page:

"
<script type="text/javascript"><!--
client = "3894758346587";
width = 800;
height = 600;
format = "image";
FirstWord; SecondWord
name = "1213131+6456456";
//-->
</script>
"

The values client, width, height, format, FirstWord, SecondWord, name
are taken from properties with the same name: Me.Client, Me.Width, ...

What is the best way to build this string.

Note that if, for example, Me.Client is empty then the code line
'client="3894758346587";' should not be added.

Thanks,
Thanks

Use a StringBuilder to create the string, then the
ClientScript.RegisterStartupScript method to add it to the page.

You can make the RegisterStartupScript method add the script tag, so
don't put that in the string, just the Javascript code.
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top