日期:2014-05-17  浏览次数:20402 次

frameset问题
ASP.NET,MVC3下使用frameset,调用frameset所在画面Index,但显示出来的是一个空白画面,不知道问题在哪.

相关代码如下:

(1) 页面代码:

HTML code


<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Menu Index</title>
</head>
<body>

<frameset name="main" rows="100,*,50" frameborder="no" border="0" framespacing="0" >
    <frame src="Menu/Top" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" />
     <frameset cols="25%,75%">
        <frame src="Menu/Left" name="LeftFrame" id="LeftFrame" />
        <frame src="Menu/Right" name="RightFrame" id="RightFrame" />
     </frameset>    
    <frame src="Menu/Bottom" name="bottomFrame" scrolling="No" noresize="noresize" id="bottomFrame" />
</frameset>

</body>
</html>




(2) Controller代码:

C# code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.Mvc;

namespace MyMvc3.Controllers.Menu
{
    public class MenuController:Controller 
    {
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Top()
        {
            ViewData["abc"] = "top";
            return View();
        }
        public ActionResult Left()
        {
            ViewData["abc"] = "left";
            return View();
        }
        public ActionResult Right()
        {
            ViewData["abc"] = "right";
            return View();
        }
        public ActionResult Bottom()
        {
            ViewData["abc"] = "bottom";
            return View();
        }
    }
}







------解决方案--------------------
frameset和<body>不能同时存在。需要删除<body></body>
------解决方案--------------------
<frame src="Menu/Left" name="LeftFrame" id="LeftFrame" />
<frame src="Menu/Right" name="RightFrame" id="RightFrame" />

要改成

<frame src="/Menu/Left" name="LeftFrame" id="LeftFrame" />
<frame src="/Menu/Right" name="RightFrame" id="RightFrame" />