Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Create String

Reply
Thread Tools

Create String

 
 
shapper
Guest
Posts: n/a
 
      10-19-2007
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

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      10-19-2007
shapper wrote:
> 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.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      10-19-2007
you could get more object oriented and use a JSON serializer.

-- bruce

shapper wrote:
> 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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java equivalent to VB 'string' function (create string with repeatingcharacters)? ohaya Java 5 10-19-2005 02:41 AM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM
Cannot create an object of type 'System.String[]' from its representation 'String[] Array' Hessam ASP .Net Building Controls 1 08-16-2003 10:26 AM
Cannot create an object of type 'System.String[]' from its representation 'String[] Array' Hessam ASP .Net Web Controls 0 08-08-2003 08:36 AM
Cannot create an object of type 'System.String[]' from its representation 'String[] Array' Hessam ASP .Net 0 08-08-2003 08:36 AM



Advertisments