C#关于网页跳转的问题
test.aspx中有左右两个框架。左边框架中页面中有一LinkButton。test.aspx.cs文件中有如下代码:
[code]
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Redirect("index.aspx");
}
[/code]
但是,index.aspx这个页面却在test.aspx的左框架显示。
如何让index.aspx完全显示出来呢?就是不显示在test.aspx左右框架中,只显示index.aspx本身(浏览器地址为http://哉名/index.aspx)。 自己顶一下!:) 不要用Redirect,用JS的location来操作。
如:
[code]
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Write("<script>parent.location.href='index.aspx';</script>");
}
[/code] 嗯,可以了,谢谢管理员!:) 又遇到了问题了。
问题如下:
test.aspx中有左右两个框架。左边框架中的一页面中有一LinkButton。
test.aspx.cs文件中有如下代码:
[code]
protected void LinkButton_Click(object sender, EventArgs e)
{
Response.Write("<script>window.parent.window.right.location='temp.aspx'</script>");
}
[/code]
上面的代码,当点击LinkButton时,左边框架还是显示原来的页面,右面的框架显示了temp.aspx页面。
但是偶写了一个类文件
[code]
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();
}
}
}
[/code]
test.aspx.cs文件中的代码修改为如下代码:
[code]
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>");
}
[/code]
这时为什么只有右框架显示页面。左框架原来的页面没有显示?
请问应该如何修改呢? 你的框架结构长什么样?
main是整个框架还是右边框架? test.aspx页面代码如下
[code]
<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>
[/code]
一开始打开test.aspx显示是正常的,但是当点击LinkButton时,左边的框架,也就是funMenu这个框架就不显示
funMenu.aspx这个页面了。right这个框架显示正常。
发现自己笔误,类中代码中应该
[code]
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();
}
}
}
[/code]
main应该改为right。但就是更改了还是同样的问题,点击后只显示右框架页面,不显示左框架菜单的页面。
[[i] 本帖最后由 zero09 于 2008-7-4 10:01 编辑 [/i]] 问题解决了
RESPONSE.END()这句去掉,就ok了。
[[i] 本帖最后由 zero09 于 2008-7-4 11:22 编辑 [/i]]
页:
[1]