How to insert hyperlink for Column Header

In the table on click of colmn headers user defined sort function should be called. So I want to give hyperlink to the column header by using anchor tag. But it is giving me errors. Below is my code. I think I am wrong in syntax. Please help me ASAP.



In my ASP file I write like this:



Response.Write “<script type=”“text/javascript”">"

Response.Write “var sXML=’<?xml version=\""1.0\"" encoding=\""UTF-8\""?>”



Response.Write “<column width=”“100"” type=""" & sFieldType & “”" align="“left”" color="“white”" sort="“na”">" & _

“<![CDATA[" & sFieldName & "]]>”





Response.write “’;”



In dhtmlGrid.js I will load XML like this:



mygrid.loadXMLString(sXML);

The syntax of XML is correct, the code must render correct link, the same code used from static XML works fine ( sample attached )
Please beware that if you output directly in js variable any single quote or new line in output will break js code.



sample.zip (1.34 KB)


Depending on the version and response buffer setting of ASP, you must break Response.Write "<script " to something like Response.Write “<scr” Response.Write "ipt ".
Or the js code breaks.
This was an issue for me a while back.
Maybe it can help you.
/Hans