[英]How to open a form, if the form is located in another folder
The form and the code that I write to be in different folders 我写在不同文件夹中的表单和代码
Code: 码:
protected string GetClientsHistoryUrl(string iinbin)
{
return "javascript:window.open('InsurerHistory.aspx?iinbin=" + iinbin.ToString() + "','_blank','status= no, resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no ')";
}
aspx: aspx:
<asp:LinkButton ID="HyperLinkIns" runat="server"
OnClientClick='<%# GetClientsHistoryUrl(Convert.ToString(Eval("iinbin"))) %>'
Text='<%# Shorten(Eval("InsName"),5,30) %>' ToolTip='<%# Eval("InsName") %>'>
</asp:LinkButton>
Error text: The resource cannot be found 错误文本: 找不到资源
Do not use Javascript in Code Behind when there is an easier solution this this. 这有一个更简单的解决方案时,请勿在“代码隐藏”中使用Javascript。
use code below: 使用以下代码:
Response.Redirect("~/ForExample/yoururl.aspx?iinbin=" + iinbin.ToString());
Then Get The Value using QueryString
in that page. 然后在该页面中使用
QueryString
获取值。
Update 更新资料
Unfortunately Specification wont work with Response.Redirect, For Specification you may want to go like this: 不幸的是,Specification无法与Response.Redirect一起使用,对于Specification,您可能想要这样:
Response.Write("<script>window.open('InsurerHistory.aspx?iinbin=" + iinbin.ToString() + "','_blank','status= no, resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no'</script>");
Good luck. 祝好运。
You can use the helper function VirtualPathUtility.ToAbsolute
to obtain the full path to the resource independently of the folder you're in... 您可以使用辅助函数
VirtualPathUtility.ToAbsolute
来获取资源的完整路径,而与您所在的文件夹无关...
Example: 例:
protected string GetClientsHistoryUrl(string iinbin)
{
string javaScript = "javascript:window.open('{0}','_blank','status= no, resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no')";
string path = VirtualPathUtility.ToAbsolute("~/Path/to/resource/InsurerHistory.aspx?iinbin=" + iinbin);
return string.Format(javaScript, path);
}
you can give absolute url in window.open() like: 您可以在window.open()中提供绝对网址,例如:
return "javascript:window.open('http://www.example.com/InsurerHistory.aspx?iinbin=" + iinbin.ToString() + "','_blank','status= no, resizable= yes, scrollbars=yes, toolbar=no,location=no,menubar=no ')";
Replace example.com with your domain. 用您的域替换example.com。
试试这个javascript
代码
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('InsurerHistory.aspx?iinbin=" + iinbin.ToString() + "','_blank')", true);
Reason: ASP.NET run time unable to locate the resource, so specify the relative path of the resource. 原因:ASP.NET运行时无法找到资源,因此请指定资源的相对路径。
for example consider the folder structure, 例如考虑文件夹结构,
About.aspx 关于.aspx
Account/Login.aspx 帐户/Login.aspx
Login.aspx page exists inside the account folder, so you need to specify the relative url just like below. Login.aspx页位于帐户文件夹内,因此您需要像下面一样指定相对URL。
<asp:LinkButton ID="HyperLinkIns" runat="server"
OnClientClick='javascript:window.open("Account/login.aspx")'
Text="Login" ToolTip="Login">
</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server"
OnClientClick='javascript:window.open("about.aspx")'
Text="About" ToolTip="About">
</asp:LinkButton>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.