If filename has single quote C# javascript does not get executed -


i need pass url c# javascript. problem if filename has single quote, not execute javascript. when use httputility.htmlencode(filenamewithoutex) execute javascript if filename "copy of david's birth certificate" url gets converted ?view.aspx?length=60&ext=pdf&file=copy of david' birth certificate.

when view.aspx tries querystring file i.e; filename, gets set "copy of david" , not "copy of david's birth certificate". because of & not rest of querystring.

 if (system.io.file.exists(filelocation)) {             string filenamewithoutext = system.io.path.getfilenamewithoutextension(filelocation);             string fileextension = system.io.path.getextension(filelocation).replace(".", "");             string title = system.io.path.getfilenamewithoutextension(filename);             string url = "view?length=" + 60+ "&ext=" + fileextension + "&file=" + filenamewithoutext;             scriptmanager.registerstartupscript(this, gettype(), "showpdf", "$(document).ready(function(){showpdfdocument('" + title + "', '" + url + "');});", true);                                       }                                        

how can send url single quote javascript?

what's best way handle ' , other special characters?

use uri.escapedatastring(yourlinkhere);. see uri.escapedatastring on msdn.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -