Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: Passing a string to a client side function

Reply
Thread Tools

Re: Passing a string to a client side function

 
 
Matt Howeson
Guest
Posts: n/a
 
      01-29-2004
I can suggest 2 similar options :

1. Put the xml string in a textbox control (and set the display style to
none using css stylesheet) then simply reference the value of your textbox
control, to get the XML string.

2. (Probably the better one) Add a hidden input field to your form, set the
runat attribute to server and then simply assign your XML string as the
value of the hidden input field from within your code behind. Using this
method the encoding is taken care of for you as the whole lot will be html
encoded. (I pretty sure this should then work fine, but I may be wrong!!)

Hope one of the above works for you.

Matt
http://www.3internet.com




"Jorell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi everyone,
> I have an XML that I create on the fly. I need to pass this to a

Javascript function and I do it in this way:
>
> Page.RegisterStartupScript("Test", "<script

language=""javascript"">printHidden('" & XML & "')</script>")
>
> This works however if you encase the XML in single quotes then there could

possibly a terminating ' in the XML and on the other hand if you encase the
XML in double quotes and there is a single " in the XML...this becomes the
terminator and the client side throws an error: Unterminated string constant
> The user enters the information the XML is built with and we must allow

them the ability to enter these any characters.
>
> What I need to do is encode the string server side before it is passed and

then unencode it on the client.
>
> I have attempted to use Regex.Escape on the Server then unescape() on the

client with no luck.
>
> Any ideas/suggestions would be great! Thank you
>
> Jorell



 
Reply With Quote
 
 
 
 
Matt Howeson
Guest
Posts: n/a
 
      01-30-2004
Jorell,

If you use the option of outputting your text to a form variable you should
not need to use escape characters at all. If you just leave the string
exactly as you want it to appear and output it to the form variables, when
you retrieve the value you should see exactly what you are looking for. Or
is there something that I am missing as to why do you need to put escape
characters in?

Matt
http://www.3internet.com


"Jorell" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi there. Thank you for the suggestion. I tried this as I figured the same

however the value, innerText and innerHtml etc properties all return the
HTML but with the escape characters ie. \"
>
> This still causes and issue and without actually doing a loop to look for

escape characters and replacing them...but there is a possibly of not
catching all of them.
>
> Essentially I am just writing this HTML to a div using the document.write

method and then printing the div using execWB.
>
> Any ideas would be great thank you!
>
> Jorell



 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9yZWxs?=
Guest
Posts: n/a
 
      01-30-2004
Hi there Matt
I actually don't want the characters in the string. What I have is Complex HTML that I have created in a server function

I have a js function which needs to take that HTML and write it to the Body of an IFrame that it creates. ( that can't be changed) So basically what I need to be able to do is end up with a variable inside that js function which is straight HTML no escapes.

Mostly the problem is if you use textboxes of any sort...the innerHtml, innerText, Text, or value fields always return the value with escape charaters when accessing them from the client. I am not sure why

So no matter what I put the HTML in, it adds escape chars

Any ideas? I appologize if it is unclear! Thank yo

Jorell
 
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
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
Passing a value from server side to client side kimberly.walker@consultant.com ASP .Net 4 07-13-2006 09:07 AM
Passing data from server side to client side? Mike Fellows ASP .Net 8 06-29-2004 03:28 PM
Re: Passing a string to a client side function Kevin Spencer ASP .Net 1 01-29-2004 08:21 PM
Passing a text string from the server side to a client side function ken busse ASP .Net 2 11-24-2003 08:18 AM



Advertisments