ASP.NET关于IFrame的问题
我在前台代码aspx中有一个IFrame控件,还有个Menu控件,在Head标记中我写了个js代码用来设置获取页面中的IFrame控件,并给它的src赋值<headrun...
我在前台代码aspx中有一个IFrame控件,还有个Menu控件,在Head标记中我写了个js代码用来设置获取页面中的IFrame控件,并给它的src赋值
<head runat="server">
<title>xxx</title>
<script language="javascript" type="text/jscript">
function setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form id="form1" runat="server">
<iframe name="iframe1" id="iframe1" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" runat="server"></iframe>
<asp:Menu ID="Menu1" runat="server" MaximumDynamicDisplayLevels="7" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false" Font-Bold="false" Font-Size="18px" onmenuitemclick="Menu1_MenuItemClick" >
<StaticMenuItemStyle HorizontalPadding="8px" />
<Items>
<asp:MenuItem Text="首页" Value="首页"></asp:MenuItem>
<asp:MenuItem Text="人员管理" Value="人员管理" Selectable="false">
<asp:MenuItem Text="人员信息查询" Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem><Menu></asp:Menu>
</form>
</body>
我在后台的aspx文件中代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace KJSys
{
public partial class Index : System.Web.UI.Page
{
static string IFrameUrl = "xxx.aspx";//设置默认的IFrame连接;
protected void Page_Load(object sender, EventArgs e)
{
string js = @"<script language='javascript'>setUrl('"+ IFrameUrl +"');</script>";
ClientScript.RegisterStartupScript(Page.GetType(), "js", js);
//Response.Write("<script>document.getElementById(\"iframe1\").src=\"" + IFrameUrl + "\";</script>");
if (!IsPostBack)
{
}
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
switch (e.Item.Value)
{
case "首页":
IFrameUrl = "PeopleSpread.aspx";
break;
case "人员信息查询":
IFrameUrl = "Search_person.aspx";
break;
}
}
}
}
为什么每次我点击菜单时,点第一次IFrame不显示跳转到新页面,点第二次才跳转?如何修改我的代码实现正常点击一次跳转?
不好意思财富值为0,没办法给悬赏。。。 展开
<head runat="server">
<title>xxx</title>
<script language="javascript" type="text/jscript">
function setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form id="form1" runat="server">
<iframe name="iframe1" id="iframe1" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" runat="server"></iframe>
<asp:Menu ID="Menu1" runat="server" MaximumDynamicDisplayLevels="7" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false" Font-Bold="false" Font-Size="18px" onmenuitemclick="Menu1_MenuItemClick" >
<StaticMenuItemStyle HorizontalPadding="8px" />
<Items>
<asp:MenuItem Text="首页" Value="首页"></asp:MenuItem>
<asp:MenuItem Text="人员管理" Value="人员管理" Selectable="false">
<asp:MenuItem Text="人员信息查询" Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem><Menu></asp:Menu>
</form>
</body>
我在后台的aspx文件中代码:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace KJSys
{
public partial class Index : System.Web.UI.Page
{
static string IFrameUrl = "xxx.aspx";//设置默认的IFrame连接;
protected void Page_Load(object sender, EventArgs e)
{
string js = @"<script language='javascript'>setUrl('"+ IFrameUrl +"');</script>";
ClientScript.RegisterStartupScript(Page.GetType(), "js", js);
//Response.Write("<script>document.getElementById(\"iframe1\").src=\"" + IFrameUrl + "\";</script>");
if (!IsPostBack)
{
}
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
switch (e.Item.Value)
{
case "首页":
IFrameUrl = "PeopleSpread.aspx";
break;
case "人员信息查询":
IFrameUrl = "Search_person.aspx";
break;
}
}
}
}
为什么每次我点击菜单时,点第一次IFrame不显示跳转到新页面,点第二次才跳转?如何修改我的代码实现正常点击一次跳转?
不好意思财富值为0,没办法给悬赏。。。 展开
2个回答
展开全部
前台:
<head id="Head1" runat="server">
<title>xxx</title>
<script language="javascript" type="text/jscript">
function setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form id="form1" runat="server">
<iframe name="iframe1" id="iframe1" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" runat="server" src="(注意!这里为默认页面)" ></iframe>
<asp:Menu ID="Menu1" runat="server" MaximumDynamicDisplayLevels="7" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false" Font-Bold="false" Font-Size="18px" onmenuitemclick="Menu1_MenuItemClick" >
<StaticMenuItemStyle HorizontalPadding="8px" />
<Items>
<asp:MenuItem Text="首页" Value="首页"></asp:MenuItem>
<asp:MenuItem Text="人员管理" Value="人员管理" Selectable="false">
<asp:MenuItem Text="人员信息查询" Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem></Items></asp:Menu>
</form>
</body>
后台:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace KJSys
{
public partial class Index : System.Web.UI.Page
{
static string IFrameUrl = null;//设置默认的IFrame连接;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
switch (e.Item.Value)
{
case "首页":
IFrameUrl = "PeopleSpread.aspx";
setJs(IFrameUrl);
break;
case "人员信息查询":
IFrameUrl = "Search_person.aspx";
setJs(IFrameUrl);
break;
}
}
public void setJs(string iframeUrl)
{
string js = @"<script language='javascript'>setUrl('" + IFrameUrl + "');</script>";
ClientScript.RegisterStartupScript(Page.GetType(), "js", js);
}
}
}
我已经调试过了,可以用!
<head id="Head1" runat="server">
<title>xxx</title>
<script language="javascript" type="text/jscript">
function setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form id="form1" runat="server">
<iframe name="iframe1" id="iframe1" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" runat="server" src="(注意!这里为默认页面)" ></iframe>
<asp:Menu ID="Menu1" runat="server" MaximumDynamicDisplayLevels="7" Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false" Font-Bold="false" Font-Size="18px" onmenuitemclick="Menu1_MenuItemClick" >
<StaticMenuItemStyle HorizontalPadding="8px" />
<Items>
<asp:MenuItem Text="首页" Value="首页"></asp:MenuItem>
<asp:MenuItem Text="人员管理" Value="人员管理" Selectable="false">
<asp:MenuItem Text="人员信息查询" Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem></Items></asp:Menu>
</form>
</body>
后台:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace KJSys
{
public partial class Index : System.Web.UI.Page
{
static string IFrameUrl = null;//设置默认的IFrame连接;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
switch (e.Item.Value)
{
case "首页":
IFrameUrl = "PeopleSpread.aspx";
setJs(IFrameUrl);
break;
case "人员信息查询":
IFrameUrl = "Search_person.aspx";
setJs(IFrameUrl);
break;
}
}
public void setJs(string iframeUrl)
{
string js = @"<script language='javascript'>setUrl('" + IFrameUrl + "');</script>";
ClientScript.RegisterStartupScript(Page.GetType(), "js", js);
}
}
}
我已经调试过了,可以用!
展开全部
前台:
<head
id="Head1"
runat="server">
<title>xxx</title>
<script
language="javascript"
type="text/jscript">
function
setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form
id="form1"
runat="server">
<iframe
name="iframe1"
id="iframe1"
frameborder="0"
scrolling="auto"
style="width:
100%;
height:
100%;"
runat="server"
src="(注意!这里为默认页面)"
></iframe>
<asp:Menu
ID="Menu1"
runat="server"
MaximumDynamicDisplayLevels="7"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false"
Font-Bold="false"
Font-Size="18px"
onmenuitemclick="Menu1_MenuItemClick"
>
<StaticMenuItemStyle
HorizontalPadding="8px"
/>
<Items>
<asp:MenuItem
Text="首页"
Value="首页"></asp:MenuItem>
<asp:MenuItem
Text="人员管理"
Value="人员管理"
Selectable="false">
<asp:MenuItem
Text="人员信息查询"
Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem></Items></asp:Menu>
</form>
</body>
后台:
using
System;
using
System.Collections;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Data.SqlClient;
namespace
KJSys
{
public
partial
class
Index
:
System.Web.UI.Page
{
static
string
IFrameUrl
=
null;//设置默认的IFrame连接;
protected
void
Page_Load(object
sender,
EventArgs
e)
{
}
protected
void
Menu1_MenuItemClick(object
sender,
MenuEventArgs
e)
{
switch
(e.Item.Value)
{
case
"首页":
IFrameUrl
=
"PeopleSpread.aspx";
setJs(IFrameUrl);
break;
case
"人员信息查询":
IFrameUrl
=
"Search_person.aspx";
setJs(IFrameUrl);
break;
}
}
public
void
setJs(string
iframeUrl)
{
string
js
=
@"<script
language='javascript'>setUrl('"
+
IFrameUrl
+
"');</script>";
ClientScript.RegisterStartupScript(Page.GetType(),
"js",
js);
}
}
}
我已经调试过了,可以用!
<head
id="Head1"
runat="server">
<title>xxx</title>
<script
language="javascript"
type="text/jscript">
function
setUrl(x)
{
document.getElementById("iframe1").src=x;
}</script>
</head>
<body>
<form
id="form1"
runat="server">
<iframe
name="iframe1"
id="iframe1"
frameborder="0"
scrolling="auto"
style="width:
100%;
height:
100%;"
runat="server"
src="(注意!这里为默认页面)"
></iframe>
<asp:Menu
ID="Menu1"
runat="server"
MaximumDynamicDisplayLevels="7"
Orientation="Horizontal"
StaticEnableDefaultPopOutImage="false"
Font-Bold="false"
Font-Size="18px"
onmenuitemclick="Menu1_MenuItemClick"
>
<StaticMenuItemStyle
HorizontalPadding="8px"
/>
<Items>
<asp:MenuItem
Text="首页"
Value="首页"></asp:MenuItem>
<asp:MenuItem
Text="人员管理"
Value="人员管理"
Selectable="false">
<asp:MenuItem
Text="人员信息查询"
Value="人员信息查询"></asp:MenuItem>
</asp:MenuItem></Items></asp:Menu>
</form>
</body>
后台:
using
System;
using
System.Collections;
using
System.Configuration;
using
System.Data;
using
System.Linq;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.HtmlControls;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Xml.Linq;
using
System.Data.SqlClient;
namespace
KJSys
{
public
partial
class
Index
:
System.Web.UI.Page
{
static
string
IFrameUrl
=
null;//设置默认的IFrame连接;
protected
void
Page_Load(object
sender,
EventArgs
e)
{
}
protected
void
Menu1_MenuItemClick(object
sender,
MenuEventArgs
e)
{
switch
(e.Item.Value)
{
case
"首页":
IFrameUrl
=
"PeopleSpread.aspx";
setJs(IFrameUrl);
break;
case
"人员信息查询":
IFrameUrl
=
"Search_person.aspx";
setJs(IFrameUrl);
break;
}
}
public
void
setJs(string
iframeUrl)
{
string
js
=
@"<script
language='javascript'>setUrl('"
+
IFrameUrl
+
"');</script>";
ClientScript.RegisterStartupScript(Page.GetType(),
"js",
js);
}
}
}
我已经调试过了,可以用!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询