打印

[.net] C#关于网页跳转的问题

test.aspx中有左右两个框架。左边框架中页面中有一LinkButton。
test.aspx.cs文件中有如下代码:
复制内容到剪贴板
代码:
protected void LinkButton_Click(object sender, EventArgs e)
    {
        Response.Redirect("index.aspx");
    }
但是,index.aspx这个页面却在test.aspx的左框架显示。
如何让index.aspx完全显示出来呢?就是不显示在test.aspx左右框架中,只显示index.aspx本身(浏览器地址为http://哉名/index.aspx)。
自己顶一下!
不要用Redirect,用JS的location来操作。
如:
复制内容到剪贴板
代码:
protected void LinkButton_Click(object sender, EventArgs e)
    {
        Response.Write("<script>parent.location.href='index.aspx';</script>");
    }
新一代四无新人……博客 | 相册
努力三件事:赚钱,技术,语言。
缺钱花了,求项目做,想低价或想比价的请勿扰。
嗯,可以了,谢谢管理员!

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
又遇到了问题了。
问题如下:
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>");
    }
这时为什么只有右框架显示页面。左框架原来的页面没有显示?
请问应该如何修改呢?

TOP

你的框架结构长什么样?
main是整个框架还是右边框架?
新一代四无新人……博客 | 相册
努力三件事:赚钱,技术,语言。
缺钱花了,求项目做,想低价或想比价的请勿扰。

TOP

test.aspx页面代码如下
复制内容到剪贴板
代码:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<link href="css/style.css" type="text/css" rel="stylesheet" />
    <title>无标题页</title>
</head>
<frameset cols="210,*" frameborder="0" framespacing="0"   bordercolor="#008000" >
    <frame name="funMenu" noresize="true" scrolling="no" src="funMenu.aspx" />
    <frame name="right" noresize="true" id= "right"  src="temp.aspx" />
</frameset>      
</html>
一开始打开test.aspx显示是正常的,但是当点击LinkButton时,左边的框架,也就是funMenu这个框架就不显示
funMenu.aspx这个页面了。right这个框架显示正常。

发现自己笔误,类中代码中应该
复制内容到剪贴板
代码:
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.right.location='" + urlStr + "'</script>");
                HttpContext.Current.Response.End();
            }
        }
    }
main应该改为right。但就是更改了还是同样的问题,点击后只显示右框架页面,不显示左框架菜单的页面。

[ 本帖最后由 zero09 于 2008-7-4 10:01 编辑 ]

TOP

问题解决了
RESPONSE.END()这句去掉,就ok了。

[ 本帖最后由 zero09 于 2008-7-4 11:22 编辑 ]

TOP