【发布时间】:2013-11-02 18:32:03
【问题描述】:
在起始页中:我想在客户端单击链接按钮lbtnEditText时将目录路径传递给弹出窗口页面
<asp:LinkButton ID="lbtnEditText" runat="server" Text="Edit Text" CommandArgument='<%# Eval("Path") + "," + Eval("Name")%>' OnCommand="Button1_Click"></asp:LinkButton>
以及背后的代码:
protected void Button1_Click(object sender, CommandEventArgs e)
{
string[] values = e.CommandArgument.ToString().Split(',');
string queryString =
"editpage.aspx?path="
+ values[0];
string newWin =
"window.open('" + queryString + "');";
ClientScript.RegisterStartupScript
(this.GetType(), "pop", newWin, true);
}
queryString 正好是 = "editpage.aspx?path=D:\\C#Projects\\website\\Lecturer\\giangvien\\profile.xml"(我在调试时检查它)
但在目标页面(弹出窗口):editpage.aspx
string path = Request.QueryString["path"];
string content = File.ReadAllText(path);
if(content!=null)
textarea.Value = content;
它有一个错误:Could not find file 'D:\C#Projects\website\C
尝试调试,我收到的path 只是:"D:C"
并在editpage.aspx的地址栏中显示:
http://localhost:41148/website/editpage.aspx?path=D:C#ProjectswebsiteLecturergiangvienprofile.xml
帮助!!!为什么我传给editpage的时候路径变了???
【问题讨论】:
-
看看url编码
标签: c# asp.net runtime-error