当前位置:编程学习 > C#/ASP.NET >>

怎样在frames中根据浏览中的URL动态添加页面!在线给分!!急!!!

网站使用frames框架
在Default.aspx中使用
<frameset rows="145,*,60" cols="*" framespacing="0" frameborder="no" border="1">
  <frame name="top" scrolling="no" noresize   src="index_top.aspx">
  <frame name="main" src="index_main.aspx" scrolling="auto">
  <frame name="bottom" scrolling="no" noresize  src="index_bottom.aspx" >
</frameset>
index_main.aspx为中间的需要动态加载页面的网页,没有任何内容,现在需要在
用户输入www.xxx.com时加载A.aspx,而在输入www.xxx.com/user/111时加载B.aspx
请各位大大帮个忙!!怎么解决? --------------------编程问答-------------------- www.xxx.com/user/111中的user/111代表用户信息 --------------------编程问答-------------------- 超连接 target="main" 不就行了 --------------------编程问答-------------------- 用这个Target就行了 --------------------编程问答-------------------- index_main.aspx根据session或querystring判断transfer到a或b页面

然后在default.aspx和/user/111/default.aspx设置session或querystring --------------------编程问答-------------------- 给你的frame 起个id 比如叫www
frame的连接就写<a href="你要连接的某个在名为id的frame出现的页面" target='www'>sdf</a>
意思就是在www这个frame里打开你的连接 --------------------编程问答-------------------- 我没有做过这样的网站,不是很明白,calmzeal,给点代码行不行 --------------------编程问答-------------------- 可以在A.aspx里面判断url里面是否有user ,如果没有可以
  window.open ( "b.aspx" , "_main" ) --------------------编程问答-------------------- 早两天才解决完一个类似的问题:
http://community.csdn.net/Expert/topic/5432/5432257.xml?temp=.5945703 --------------------编程问答-------------------- 我想只有calmzeal明白我的意思,我知道target的用法,现在是在用户的浏览器里输入不同的URL,我要加载的是带了不同导航功能的页面,所以在index_main.aspx里面没有任何的实际内容,也没有导航控件 --------------------编程问答-------------------- if(HttpContext.Current.Request.Url.ToString().IndexOf("user/111")>0)
{
this.main.Attributes.Add("src","你要转向的页面");
} --------------------编程问答-------------------- http://www.cnblogs.com/ipusr/articles/596841.html
获取当前网址信息,然后根据不同的网址给main框架的src赋值,不知道是不是LZ所要的方法呢? --------------------编程问答-------------------- if(HttpContext.Current.Request.Url.ToString().IndexOf("user/111")>0)
{
this.main.Attributes.Add("src","你要转向的页面");
}
是写在Default.aspx中的吗?
--------------------编程问答-------------------- 获取当前网址信息,然后根据不同的网址给main框架的src赋值,不知道是不是LZ所要的方法呢?
对!就是这样的 ! --------------------编程问答-------------------- 如果有多个的页是动态的有规律的,当然也可以通过截取字符串获得后面的用户名(如从www.xxx.com/user/111获得111):
int sindex=HttpContext.Current.Request.Url.ToString().LastIndexOf("/")+1;
int eindex=HttpContext.Current.Request.Url.ToString().Length();
string struser=HttpContext.Current.Request.Url.ToString().Substring(sindex,eindex-sindex);
this.main.Attributes.Add("src",struser+".aspx");

--------------------编程问答-------------------- if(HttpContext.Current.Request.Url.ToString().IndexOf("user/111")>0)
{
this.main.Attributes.Add("src","你要转向的页面");
}
是写在Default.aspx中的吗?

对啊,通过Default.aspx来控制main框架的src属性吗 --------------------编程问答-------------------- 整体需要页面重新导航,下面是对index_main.aspx写的一个Javascript,原理应该是一样的,你自己改吧!
<script language=javascript >
    <!--
      function winload()
      {
       var loc=location.href;
       var I=loc.indexOf("/user/");
     
        if (I !=-1)
          location.reload ("B.aspx") 
        else
         location.reload("A.aspx"); 
       }
    -->
    </script>
  </head>
  <body MS_POSITIONING="GridLayout" onload=winload()> --------------------编程问答-------------------- 提一个忠告,一定谨慎使用IFRAME,因为在IE7环境,性能会不太好.你可以使用ASP.NET容量控件来处理,比如,WEBPART我觉得就非常好! --------------------编程问答-------------------- 我在Default.aspx.cs的page_load中写if(HttpContext.Current.Request.Url.ToString().IndexOf("user/111")>0)
{
this.main.Attributes.Add("src","你要转向的页面");
}
  this后面点不出main --------------------编程问答-------------------- 为什么非要去分桢呢?我一直都不赞成,在同一个页面进行处理的话,很容易进行变量传递,不需要去构造过多的方法。 --------------------编程问答-------------------- main后面加属性:runat=server
<frame name="main" src="index_main.aspx" scrolling="auto" runat=server>
--------------------编程问答-------------------- 我没使用Iframe 用的frames,嘿嘿 --------------------编程问答-------------------- 为什么要分桢是因为基本页面都一样,只有功能使用和数据显示方面的不同,我懒得画页面 --------------------编程问答-------------------- 还是不对啊,main后面加属性:runat=server
<frame name="main" src="index_main.aspx" scrolling="auto" runat=server>,加了没用 --------------------编程问答-------------------- 那就只能用javascript的方法了,在index_main.aspx文件里面用setfocus(斗是懂一点) 的方法:

<script language=javascript >
    <!--
      function winload()
      {
       var loc=location.href;
       var I=loc.indexOf("/user/111");
     
        if (I !=-1)
          location.reload ("B.aspx") 
        else
         location.reload("A.aspx"); 
       }
    -->
    </script>
  </head>
  <body MS_POSITIONING="GridLayout" onload=winload()>
--------------------编程问答-------------------- 不用改吗? --------------------编程问答-------------------- 还是不对啊,main后面加属性:runat=server
<frame name="main" src="index_main.aspx" scrolling="auto" runat=server>,加了没用

加上ID啊,哥哥,这么写:
<frame name="main" id="main" src="index_main.aspx" scrolling="auto" runat=server>

CS的PAGELOAD里复制下面的内容
if(HttpContext.Current.Request.Url.ToString().IndexOf("user/111")>0)
{
this.main.Attributes.Add("src","你要转向的页面");
}
--------------------编程问答-------------------- 不对,还是不行 main后面点不会出现在属性 --------------------编程问答-------------------- 我这也有个类似的应用。不过我用的是容器,每个Panel 中都有GridView,而且都绑定了数据源。
现在但有个疑问?这样虽然在判断URL中的内容后,有些PANEL在页面没有显示出来。是不是也同样消耗了服务器资源呢?
protected void Page_Load(object sender, EventArgs e)
    {
        //URL中只有一个最基本的查询信息
        if (Request.QueryString.Count == 1)
        {
            this.Panel2.Visible = true;
            this.Panel1.Visible = false;
            this.PanelComList.Visible = false;
        }
        else
        {
            string com_name = Request.QueryString.Get("com_name");
            if (com_name.Length==0)
            {
               //URL中没有单位名称                
                this.PanelComList.Visible = true;
                this.Panel1.Visible = false;
                this.Panel2.Visible = false;
            }
            else
            {
                this.Panel1.Visible = true;
                this.Panel2.Visible = false;
                this.PanelComList.Visible = false;
            }
        } 
    } --------------------编程问答-------------------- 不明白 在控件的 Visible = false 情况下,服务器有没有也做数据绑定的工作。
我知道 数据显示控件 的 Enabled=false 情况下,还是进行了数据绑定操作的。只是不能操作而已。 --------------------编程问答-------------------- 路过~ --------------------编程问答-------------------- up --------------------编程问答-------------------- 路过 --------------------编程问答-------------------- 路过 --------------------编程问答-------------------- lu guo --------------------编程问答-------------------- 该回复被版主删除 --------------------编程问答-------------------- 做个记号 --------------------编程问答-------------------- 先把src设成动态改变的src="<%=wsearch%>" 例如:
<frameset rows="147,*" frameborder="no" framespacing="0">
<frame name="wsearch" src="<%=wsearch%>" scrolling=auto noresize>
<frameset cols="200,*">
<frame name="wchikutok" src="<%=wchikutok%>" noresize scrolling=auto>
<frame name="wresult" src="<%=wresult%>">
</frameset>
</frameset>
然后在后台代码中定义公共变量
    Public wsearch As String
    Public wchikutok As String
    Public wresult As String
再在后台代码的初始化或者页面事件中改变公共变量的值为url就OK了
刚做过这样的页面,所以比较清楚 --------------------编程问答-------------------- 你的具体的做法如下:
<frameset rows="145,*,60" cols="*" framespacing="0" frameborder="no" border="1">
  <frame name="top" scrolling="no" noresize   src="index_top.aspx">
  <frame name="main" src="<%=Wsearch%>" scrolling="auto">
  <frame name="bottom" scrolling="no" noresize  src="index_bottom.aspx" >
</frameset>
在后台代码中定义全局变量Wsearch
public Wsearch as string
页面初始化的时候
page_load:
if Request.QueryString("user")=111 then
Wsearch="B.aspx"
else
Wsearch="A.aspx"
end if
我学的是VB你自己转成其他语言

--------------------编程问答-------------------- 我测试了,但只解决了一部分问题啊,当我输入www.xxx.com/user/111时,直接打开了B.aspx只有在用Default.aspx启动时才会进行动态加载,前面说的没有加入到框架里面去啊!
yuanwen813()大哥,怎么会事情,帮帮忙! --------------------编程问答-------------------- up --------------------编程问答-------------------- up
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,