在 asp.net 中打开的窗口中的 Server.MapPath
我想在用户单击按钮时打开一个新的弹出窗口。但是我面临一个问题,如何基于 server.mapPath 打开一个新的弹出窗口? 这是我的编码
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open(" + Server.MapPath("~/reportPreview.aspx") + ", '', '');");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(),"test", sb.ToString());
,但我无法打开新窗口。请帮忙:(
i want to open a new pop up window when user click the button.But nw i facing a problem, how can i open a new pop up window based on server.mapPath?
Here is my coding
StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open(" + Server.MapPath("~/reportPreview.aspx") + ", '', '');");
sb.Append("</script>");
ClientScript.RegisterStartupScript(this.GetType(),"test", sb.ToString());
But i cant open a new window . Please help :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
window.open
需要一个类似“../reportPreview.aspx”的 URL,但Server.MapPath
返回类似“C:\YourApp\reportPreview.aspx”的物理路径。您应该改为调用ResolveClientUrl
。此外,您还需要在 URL 两边添加引号:window.open
expects a URL like "../reportPreview.aspx", butServer.MapPath
returns a physical path like "C:\YourApp\reportPreview.aspx". You should callResolveClientUrl
instead. Also, you need to add quotes around the URL: