0

I have an application in which the user would open the document clicking the a linkbutton which opens the path of document

if (e.CommandArgument.ToString().ToLower().IndexOf(".pdf") > 0)
        ScriptManager.RegisterStartupScript(Page, this.GetType(), "myPopUp", "<script language='Javascript'>mywin=window.open('file:" + e.CommandArgument.ToString().Trim().Replace("\\", "/") + "', '', 'location=0,status=0,resizable=1,scrollbars=1,height=800px, width=1000px');</script>", false);

In this when the filename is something like xyz## it is reading as xyz#

and if filename is like xyz# it is reading xyz

Any solution?

Bebu
  • 65
  • 3
  • 14
  • Is this C# ?. My mistake. I'm not into C#. Sorry. – NT_ May 03 '12 at 18:52
  • You can read through [this](http://stackoverflow.com/questions/86477/does-c-sharp-have-an-equivalent-to-javascripts-encodeuricomponent) for more insight . – NT_ May 03 '12 at 18:54

2 Answers2

0
if (e.CommandArgument.ToString().ToLower().IndexOf(".pdf") > 0)
    ScriptManager.RegisterStartupScript(Page, this.GetType(), "myPopUp", "<script language='Javascript'>mywin=window.open('file:" + e.CommandArgument.ToString().Trim().Replace("\\", "/") + "', '', 'location=0,status=0,resizable=1,scrollbars=1,height=800px, width=1000px');</script>", false);

Replace above with this instead:

if (e.CommandArgument.ToString().ToLower().IndexOf(".pdf") > 0)
    ScriptManager.RegisterStartupScript(Page, this.GetType(), "myPopUp", "<script language='Javascript'>mywin=window.open('file:" + e.CommandArgument.ToString().Trim().Replace("\\", "/") + "', **'_self'**, 'location=0,status=0,resizable=1,scrollbars=1,height=800px, width=1000px');</script>", false);

solved the problem.

Rondel
  • 4,811
  • 11
  • 41
  • 67
Bebu
  • 65
  • 3
  • 14
0

In my opinion... These are exactly these problems which are caused by IE but by benevolent programmer too.

As better solution I see something like this:

window.open('scriptUrl?parameters')

and inside script get file name from parameters and return file after redirect or similarly.