.net
  • url
  • special-characters
  • filenames
  • window.open
  • 2012-05-03 74 views 0 likes 
    0

    我在其中用戶將打開文檔單擊一個LinkBut​​ton將打開的文檔特殊字符需要打開文件

    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); 
    

    的路徑在這個應用程序時的文件名是像XYZ ##是讀爲XYZ#

    ,如果文件名是一樣的xyz#它是閱讀XYZ

    任何解決方案?

    +0

    這是C#嗎?我的錯。我沒有進入C#。抱歉。 – Niranjan

    +0

    感謝您嘗試通過:) – Bebu

    +0

    您可以閱讀[this](http://stackoverflow.com/questions/86477/does-c-sharp-have-an-equivalent-to-javascripts-encodeuricomponent)以獲取更多見解。 – Niranjan

    回答

    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); 
    

    替換上面這個代替

    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); 
    

    解決了這個問題。

    0

    在我看來......這些正是這些問題,這些問題是由IE引起的,但也是由仁慈的程序員造成的。

    由於更好的解決方案我看到這樣的事情:(「?在scriptUrl參數」)

    window.open

    和內部腳本參數獲取文件名和重定向後或類似的返回文件。

    相關問題