Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在aspx页面中访问文件路径_Javascript_Asp.net_Html_C# 4.0 - Fatal编程技术网

Javascript 如何在aspx页面中访问文件路径

Javascript 如何在aspx页面中访问文件路径,javascript,asp.net,html,c#-4.0,Javascript,Asp.net,Html,C# 4.0,在这里,我在页面顶部声明了字符串变量,如下所示 public string path; protected void ViewFile(object sender, EventArgs e) { path = (sender as LinkButton).CommandArgument; this.Page.ClientScript

在这里,我在页面顶部声明了字符串变量,如下所示

public string path; 
             protected void ViewFile(object sender, EventArgs e)
                        {
                 path = (sender as LinkButton).CommandArgument;
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(),"page_index_script","openPDF();",true);
                } 
<script type="text/javascript">
                function openPDF() {
                    var strMessage ='<%= path%>';
                    var filepath = 'http://localhost:2878/your project name/' + strMessage;
                window.open(filepath , 'PDF');
                return true;
            }
        </script>
我想在aspx页面的脚本标记内访问这个变量,如下所示

public string path; 
             protected void ViewFile(object sender, EventArgs e)
                        {
                 path = (sender as LinkButton).CommandArgument;
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(),"page_index_script","openPDF();",true);
                } 
<script type="text/javascript">
                function openPDF() {
                    var strMessage ='<%= path%>';
                    var filepath = 'http://localhost:2878/your project name/' + strMessage;
                window.open(filepath , 'PDF');
                return true;
            }
        </script>

函数openPDF(){
var strMessage='';
var filepath=http://localhost:2878/your 项目名称/'+strMessage;
打开(文件路径,'PDF');
返回true;
}
但是保存文件路径的变量不包括“/”,因为它将文件路径视为字符串 然后从该路径生成“/”。但我不需要想象,怎么可能呢? 假设文件路径类似于“file/Admin/PMS”
但是当我将strMessage、filepath作为“fileAdminPMS”发出警报时,它给了我一个提示。

它消除了前斜杠是什么意思?什么是
警报(a)给你什么?请粘贴准确的文本。另外,最好给变量命名,因为
p
和'a'根本不清楚它们的用途。警告(a)以字符串形式提供filepath,但它会从该filepath中删除所有“/”正斜杠…假设filepath类似于D://file/TMS/…但它会以D:filetms的形式发出警报我已经更新了它…因为我需要在新的窗口选项卡中打开文件,但filepath不是它应该的样子