又遇到了问题了。
问题如下:
test.aspx中有左右两个框架。左边框架中的一页面中有一LinkButton。
test.aspx.cs文件中有如下代码:
复制内容到剪贴板
代码:
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Write("<script>window.parent.window.right.location='temp.aspx'</script>");
}上面的代码,当点击LinkButton时,左边框架还是显示原来的页面,右面的框架显示了temp.aspx页面。
但是偶写了一个类文件
复制内容到剪贴板
代码:
public class RedirectUrl {
public RedirectUrl(){
}
public void Url(string urlStr) {
if ((HttpContext.Current.Session["user"]).ToString() == "admin") {
HttpContext.Current.Response.Write("<script>window.parent.window.main.location='" + urlStr + "'</script>");
HttpContext.Current.Response.End();
}
}
}test.aspx.cs文件中的代码修改为如下代码:
复制内容到剪贴板
代码:
public partial class funMenu : System.Web.UI.Page
{
RedirectUrl RedirectUrl = new RedirectUrl();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkButton_Click(object sender, EventArgs e)
{
RedirectUrl.Url("temp.aspx");
//Response.Write("<script>window.parent.window.right.location='temp.aspx'</script>");
}这时为什么只有右框架显示页面。左框架原来的页面没有显示?
请问应该如何修改呢?