I am using javascript to open save dialog box
the java script is
function openDialog(path) {
document.execCommand("SaveAs",true,path);
}
In my project, i am creating linkButtons dynamically and attaching this function with linkButton's OnClient Click event at run time.
LinkButton linkButton = new LinkButton();
linkButton.OnClientClick = "openDialog("+file.ToString()+")";
where "file" contains the path of the file which has to be saved.
But i am getting a javascript error as
"Expected ")" "
can anyone help me in what i am doing wrong in this.
I have N number of dynamically created linkButtons and i am associating each linkButton with different file.
You are not quoting your string so it renders as:
openDialog(someFileName.ext);
which is not valid JavaScript. Change your C# code to read:
linkButton.OnClientClick = "openDialog('"+file.ToString()+"')";
This will render to the browser as:
openDialog('someFileName.ext');
which is valid JavaScript.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.