ASP.NET(使用 VB.NET 进行代码隐藏)框架问题
我正在为我的网络应用程序使用框架。 描述 (1)左框架带有按钮列表(单击它们会在右框架中打开网页) (2)右框,打开左框经过的网页。
问题:按钮单击在生产计算机、Windows XP、32 位上的 Internet Explorer 8.0 中正常工作。
按钮单击事件不会在右框架中打开任何内容,只是保持原样,在 Firefox、Chrome、Internet Explorer 9.0
加载框架的初始代码
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="frmMain.aspx.vb" Inherits="XYZ" smartNavigation="True"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>frmMain</</TITLE>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<frameset COLS="20%,80%">
<frame name="frame1" src="frmbuttons.aspx">
<frame name="frame2" src="frmbegin.aspx">
</frameset>
示例代码(左框架中的按钮):
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
Dim url As String = String.Empty
url = "test.aspx"
Dim frameScript As String = "<script language='javascript'>" & "window.parent.frames(1).location='" & url & "';</script>"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "FrameScript", frameScript, False)
end sub
任何帮助将不胜感激。
I am using frames for my web application.
Description
(1)Left Frame with a list of buttons (clicking them opens a web page in the right frame)
(2)Right Frame, opens the web page passed by the left frame.
Problem: Button click works perfectly in Internet Explorer 8.0 on production machine, Windows XP, 32 bit.
Button click event doesn't open anything in the right frame, just remains as it is, in
Firefox, Chrome, Internet Explorer 9.0
Intial code that loads the frames
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="frmMain.aspx.vb" Inherits="XYZ" smartNavigation="True"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>frmMain</</TITLE>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<frameset COLS="20%,80%">
<frame name="frame1" src="frmbuttons.aspx">
<frame name="frame2" src="frmbegin.aspx">
</frameset>
Example code (for a button in left frame):
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
Dim url As String = String.Empty
url = "test.aspx"
Dim frameScript As String = "<script language='javascript'>" & "window.parent.frames(1).location='" & url & "';</script>"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "FrameScript", frameScript, False)
end sub
Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我找到了解决方案。此代码会导致错误:
由于括号
()
,上面的行在window.parent.frames(1)
中出现错误;此问题的正确解决方案是:此代码是正确的:
VB.Net 使用括号进行数组索引访问,但 Javascript 使用方括号。一旦我更改为正确的语法,代码就可以在所有浏览器中正常运行。
I found the solution. This code causes an error:
The above line has an error in
window.parent.frames(1)
because of the parenthesis()
; the correct solution to this problem would be:This code is correct:
VB.Net uses parenthesis for array index access, but Javascript uses square brackets. Once I changed to the correct syntax, the code worked fine in all browsers.
你尝试过吗:
根据我使用 ScriptManager 的经验,我从来不需要标签,而且它总是在 IE、chrome 和 FF 中工作。
Have you tried:
In my experience with ScriptManager, I've never needed the tags, and it's always worked in IE, chrome and FF.