ASP.NET(使用 VB.NET 进行代码隐藏)框架问题

发布于 2024-12-01 01:29:19 字数 1621 浏览 0 评论 0原文

我正在为我的网络应用程序使用框架。 描述 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

£冰雨忧蓝° 2024-12-08 01:29:19

我找到了解决方案。此代码会导致错误:

Dim frameScript As String = "window.parent.frames(1).location='" & url & "'"

由于括号 (),上面的行在 window.parent.frames(1) 中出现错误;此问题的正确解决方案是:

此代码是正确的:

Dim frameScript As String = "window.parent.frames[1].location='" & url & "'"

VB.Net 使用括号进行数组索引访问,但 Javascript 使用方括号。一旦我更改为正确的语法,代码就可以在所有浏览器中正常运行。

I found the solution. This code causes an error:

Dim frameScript As String = "window.parent.frames(1).location='" & url & "'"

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:

Dim frameScript As String = "window.parent.frames[1].location='" & url & "'"

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.

九命猫 2024-12-08 01:29:19

你尝试过吗:

Dim frameScript As String = "window.parent.frames(1).location='" & url & "'"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "FrameScript", frameScript, False)

根据我使用 ScriptManager 的经验,我从来不需要标签,而且它总是在 IE、chrome 和 FF 中工作。

Have you tried:

Dim frameScript As String = "window.parent.frames(1).location='" & url & "'"
ScriptManager.RegisterStartupScript(Me.Page, Me.Page.GetType, "FrameScript", frameScript, False)

In my experience with ScriptManager, I've never needed the tags, and it's always worked in IE, chrome and FF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文