这是一个奇怪的问题,我甚至无法找到一个好的方式来回答谷歌。
我有一个使用主页/内容页面的asp.net Web表单站点。在一个页面上,javascript函数位于顶部,名为" rePrintPrompt"。当我运行该站点时,使用localhost来测试javascript函数名称就会出现在asp面板的上方。
我无法在显示功能名称的代码中的任何位置找到它。
这是aspx代码:
<%@ Page Title="" Language="VB" MasterPageFile="~/SiteMaster.master" AutoEventWireup="false" CodeFile="Reports.aspx.vb" Inherits="Reports" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<link href="SiteStyleSheet.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="images/fav_icon_OGI_Logo.PNG" type="image/x-icon" />
<%-- Javascript to check reprint function --%>
<script type="text/javascript">
function rePrintPrompt()
{
var answer = prompt("Is this a reprint job? Y/N", "N")
if (answer == null || answer == "")
{
answer = prompt("Is this a reprint job? Y/N", "N")
} else if(answer == "Y")
{
var answer2 = prompt("Please enter Order #, Mark #, and Qty:")
if (answer2 == nul || answer2 == "")
{
answer2 = prompt("Please enter Order #, Mark #, and Qty:")
} else
{
var answers = str.split(",")
document.getElementById('<%= hOrderNumber.ClientID %>').value = answers[0]
document.getElementById('<%= hMarkNumber.ClientID %>').value = answers[1]
document.getElementById('<%= hQty.ClientID %>').value = answers[2]
document.getElementById('<%= hRePrint.ClientID %>').value = "Y"
document.getElementById('<%= btnPieceLabels.ClientID %>').click()
}
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MasterContentLeft" Runat="Server">
<div id="RptOptBtn">
<asp:Button ID="btnBanding" runat="server" CssClass="DCLButton" Text="Banding Rpt" />
<asp:Button ID="btnBearingBar" runat="server" CssClass="DCLButton" Text="Bearing Bar Rpt" />
<asp:Button ID="btnCrossBar" runat="server" CssClass="DCLButton" Text="Cross Bar Rpt" />
<asp:Button ID="btnPackingList" runat="server" CssClass="DCLButton" Text="Packing List Rpt" />
<asp:Button ID="btnBatchLabels" runat="server" CssClass="DCLButton" Text="Batch Labels" />
<asp:Button ID="btnPieceLabels" runat="server" CssClass="DCLButton" Text="Piece Labels" OnClientClick="rePrintPrompt();" />
<asp:Button ID="btnClose" runat="server" CssClass="DCLButton" Text="Close" />
<asp:HiddenField runat="server" ID="hLabelType" />
<asp:HiddenField runat="server" ID="hOrderNumber" />
<asp:HiddenField runat="server" ID="hMarkNumber" />
<asp:HiddenField runat="server" ID="hQty" />
<asp:HiddenField runat="server" ID="hRePrint" />
</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MasterContentRight" Runat="Server">
<div id="RptPanels">
<asp:Panel ID="pnlBandingRpt" runat="server" Width="990px" Visible="false">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="rvBanding" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/Banding" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
<asp:Panel ID="pnlPackingList" runat="server" Width="990px" Visible="false">
<rsweb:ReportViewer ID="rvPackingList" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/PackingList" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
<asp:Panel ID="pnlCrossBarRpt" runat="server" Width="990px" Visible="false">
<rsweb:ReportViewer ID="rvCrossBar" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/CrossBarRpt" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
<asp:Panel ID="pnlBearingBarRpt" runat="server" Width="990px" Visible="false">
<rsweb:ReportViewer ID="rvBearingBar" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/BearingbarRpt" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
<asp:Panel ID="pnlBatchLabels" runat="server" Width="990px" Visible="false">
<rsweb:ReportViewer ID="rvBatchLabels" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/BatchLabel" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
<asp:Panel ID="pnlPieceLabels" runat="server" Width="990px" Visible="false">
<rsweb:ReportViewer ID="rvPieceLabels" runat="server" BackColor="White" Width="990px" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" AsyncRendering="False" ShowBackButton="False" ShowCredentialPrompts="False" ShowDocumentMapButton="False" ShowExportControls="False" ShowFindControls="False" ShowParameterPrompts="False" ShowPromptAreaButton="False" ShowRefreshButton="False" ShowZoomControl="False" SizeToReportContent="True">
<ServerReport ReportPath="/OGI Department Folders/Production/PieceLabels" ReportServerUrl="http://sql4/ReportServer_SQL4" />
</rsweb:ReportViewer>
</asp:Panel>
</div>
</asp:Content>
为什么要显示名称?我以前从未见过这种情况。
非常感谢任何帮助。
编辑:在后面的代码中,这是引用该函数的唯一位置:
Private Sub Reports_Load(sender As Object, e As EventArgs) Handles Me.Load
'Get passed order number
oNumber = Request.QueryString("ordernum").ToString()
btnPieceLabels.Attributes.Add("onclick", "rePrintPrompt")
If Not ClientScript.IsStartupScriptRegistered("rePrintPrompt") AndAlso Not IsPostBack Then
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "rPrintLabels", "rePrintPrompt")
End If
使用浏览器开发人员工具检查页面后,我发现了这个:
我不知道为什么会将此添加到页面中。
答案 0 :(得分:0)
好的,所以经过几个月弄乱这个问题后,我终于找到了问题的来源。
在页面加载的代码隐藏文件中,我有一个客户端注册脚本行:
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "cqar", "closeqar")
在双引号中具有closeqar的最后一个段是流氓文本的来源。我只是将其更改为&#34;&#34;文字消失了。所以这一行现在写着:
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "cqar", "")
答案 1 :(得分:0)
我认为问题在于你根本不需要RegisterClientScriptBlock
。您的脚本已在页面上。 RegisterClientScriptBlock
用于向页面添加新脚本。您所需要的只是Attributes.Add
部分。
btnPieceLabels.Attributes.Add("onclick", "rePrintPrompt")
// If Not ClientScript.IsStartupScriptRegistered("rePrintPrompt") AndAlso Not IsPostBack Then
// ClientScript.RegisterClientScriptBlock(Me.[GetType](), "rPrintLabels", "rePrintPrompt")
// End If
(我不确定vb.net中的评论是否为双斜线或滴答。)
编辑:我刚注意到您的按钮上已经有OnClientClick,因此您也不需要btnPieceLabels.Attributes.Add
。