Create String

  • Thread starter Thread starter shapper
  • Start date Start date
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
 
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.
 
Back
Top