开发者

How to escape characters in this URL

I have the following code:

onclick='window.open(" ***  ","List","scrollbars=no,resizable=no,width=400,height=280");'

I want to replace the *** with this:

<%# "~/pages/AttchmentViewer.aspx?ID=" + Eval("ID").ToString() %>

but I have problems with the result with the quotation marks:

<a runat="server" id="DocTitleLabel" 

onclick='window.open(\"<%# "~/pages/AttchmentViewer.aspx?ID=" + 
Eval("ID").ToString()  %>" \", "List", "sc开发者_StackOverflow中文版rollbars=no,resizable=no,width=400,height=280");'>

      <%# Eval("DocTitle") %> 
</a>

Any help!!!

Thanks in advance.


This should work (tested), but as I told you the ~ must be omitted you just need to give relative path,

onclick='<%# "window.open(\"~/pages/AttchmentViewer.aspx?ID=" + Eval("Id").ToString() + "\", \"List\",\"scrollbars=no,resizable=no,width=400,height=280\");" %>'


You're escaping the wrong quotation marks, the ones inside the URL need to be escaped not the ones around it.. Also encoding the query-string is a good idea.

So try onclick='window.open("<%# \"~/pages/AttchmentViewer... instead of onclick='window.open(\"<%# "~/pages/AttchmentViewer.... (same applies for the closing marks)

Although I wonder what the server-tags (<% %>) will do ...


You've got to urlencode the string

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜