我正在对一个旧的Web程序进行一些修改,并且在测试过程中碰到了上面的警告消息。
以下是参考代码的一部分:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="PIB_ModelMast.aspx.vb" Inherits="NetApps.PIB_MODELMAST" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>PIB_MODELMAST</title>
<meta content="True" name="vs_showGrid">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<script language="javascript">
function confirm_delete()
{
if (confirm("Do you want to delete record?")==true)
return true;
else
return false;
}
function confirm_Edit(id) {
var theForm = document.forms[0]
traschURL="PIB_MODELADD.aspx?ID=" + id
traschWin = launchCenter(traschURL, 'traschWin', 650, 900)
return false;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" borderColor="aqua"
height="50" cellSpacing="0" cellPadding="0" width="100%" bgColor="darkblue" border="1">
<TR>
<TD>
<center><FONT face="Arial" color="#ffffff" size="5"><STRONG>MODEL AND LINE MASTER
MAINTENANCE</STRONG></FONT></center>
</TD>
</TR>
</TABLE>
<TABLE id="Table2" style="Z-INDEX: 102; LEFT: 8px; POSITION: absolute; TOP: 80px; HEIGHT: 56px"
cellSpacing="0" cellPadding="0" width="100%" bgColor="lightgrey" border="0">
<TR>
<TD style="WIDTH: 121px"><STRONG><FONT face="Arial"></FONT></STRONG></TD>
<TD style="WIDTH: 125px"><FONT face="Arial"><STRONG>MODEL</STRONG></FONT></TD>
<TD style="WIDTH: 664px"><asp:textbox id="ModelText" runat="server" Height="27px" Width="469px" Font-Size="Small"></asp:textbox></TD>
<TD style="WIDTH: 209px"><asp:button id="Button1" runat="server" Width="95px" Text="Filter" Font-Bold="True" Height="35px"></asp:button></TD>
<TD style="WIDTH: 74px"><asp:button id="Button2" runat="server" Width="96px" Text="Add New" Font-Bold="True" Height="35px"></asp:button></TD>
<TD style="WIDTH: 138px"></TD>
</TR>
</TABLE>
<asp:datagrid id="DataGrid1" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 168px"
runat="server" Width="100%" GridLines="Horizontal" BorderColor="Aqua" OnDeleteCommand="DataGrid1_DeleteCommand"
DataKeyField="ID" CellPadding="5" AutoGenerateColumns="False" ShowFooter="True" BackColor="PaleTurquoise">
<FooterStyle BackColor="#000099"></FooterStyle>
<SelectedItemStyle Font-Bold="True" ForeColor="MidnightBlue"></SelectedItemStyle>
<EditItemStyle BackColor="PaleTurquoise"></EditItemStyle>
<AlternatingItemStyle Font-Size="X-Small" Font-Names="Arial" BackColor="Wheat"></AlternatingItemStyle>
<ItemStyle Font-Size="X-Small" Font-Names="Arial"></ItemStyle>
<HeaderStyle Font-Size="X-Small" Font-Names="Arial" Font-Bold="True" ForeColor="White" BackColor="#000099"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="ID" SortExpression="ID" HeaderText="Id"></asp:BoundColumn>
<asp:BoundColumn DataField="Model" SortExpression="Model" HeaderText="Model">
<HeaderStyle Width="200px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Line" SortExpression="Line" HeaderText="Line">
<HeaderStyle Width="200px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Process" SortExpression="Process" HeaderText="Process">
<HeaderStyle Width="200px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="PZone" SortExpression="PZone" HeaderText="PZone">
<HeaderStyle Width="200px"></HeaderStyle>
</asp:BoundColumn>
<asp:ButtonColumn Text="Edit" CommandName="Edit">
<HeaderStyle Width="100px"></HeaderStyle>
</asp:ButtonColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete">
<HeaderStyle Width="100px"></HeaderStyle>
</asp:ButtonColumn>
</Columns>
</asp:datagrid></form>
</body>
其余代码用于构建GridView。 GridView将有一列,每行都有删除按钮和编辑按钮。单击任何行上的编辑将导致出现此警告消息。
JavaScript runtime error: 'launchCenter' is undefined
“ launchCenter”出现在代码的Confirm_Edit函数中,我试图将其注释掉,因为我最初的想法是由于未定义,因此它是未使用的代码。但这最终导致GridView中的“编辑”按钮停止工作。
此外,即使我收到警告消息,如果单击“继续”,程序也将继续正常运行,并且可以在GridView中编辑并保存更改。实时版本也是如此。未检测到问题。
现在,我只想修复代码,以使消息不会出现。有什么帮助吗?如有必要,我会添加更多代码。