c# string problem

  • Thread starter Thread starter Blue Man
  • Start date Start date
B

Blue Man

hello
I am trying to generate a JavaScript code with asp.net pages. the generated
code contains special characters like "/" "<" and so , but when i get the
code it is changed to somthing else like : &lt;a

string temp = "<a href="+link[0]+" \"a>" + "Link</a>";

writer.WriteString(" document.write('"+temp+"'); ");

the compiler changes the characters and because of that the javascript
returens error messages. i also tried @ befor my temp string but didn't
work.

how can i avoid this?
 
Hi,

Look up the Page.RegisterClientScriptBlock() method in MSDN,
this contains a sample of how to add JavaScript to an ASP.net page.

Chris
 
Thank you Christopher
actually i solved the problem with "response.write()" method istead of XML
writer.
but i will look at that also.


Christopher Kimbell said:
Hi,

Look up the Page.RegisterClientScriptBlock() method in MSDN,
this contains a sample of how to add JavaScript to an ASP.net page.

Chris


Blue Man said:
hello
I am trying to generate a JavaScript code with asp.net pages. the generated
code contains special characters like "/" "<" and so , but when i get the
code it is changed to somthing else like : &lt;a

string temp = "<a href="+link[0]+" \"a>" + "Link</a>";

writer.WriteString(" document.write('"+temp+"'); ");

the compiler changes the characters and because of that the javascript
returens error messages. i also tried @ befor my temp string but didn't
work.

how can i avoid this?
 
Back
Top