ASP.Net Button不提高回发 [英] ASP.Net Button not raising postback

查看:79
本文介绍了ASP.Net Button不提高回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我们的一个Web应用程序中有一个简单的页面,该页面具有以下标记:

I've a simple page in one of our web applications, which has the following markup:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewUpload.aspx.cs" Inherits="Mass_Upload.NewUpload" MasterPageFile="~/Master" Title="Document Mass Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="Stylesheet" type="text/css" href="./../CSS/ScrollingTable.css" />
    <script type="text/javascript" src="../Help/HelpPopup.js" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CenterH1" runat="server">
    Document Mass Upload <a href="javascript:loadHelpVid(5)"><img style="Border:None;" src="../Help/help_icon.gif" /></a>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="CenterBody" runat="server">
    <h3>Add New Upload</h3>
    <table class="list">
        <tr>
            <td class="label" style="text-align:right;">Local File:</td>
            <td class="normal">
                <asp:FileUpload ID="fuFilename" runat="server" Width="405" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Text="*"
                            ErrorMessage="A file to upload is required"
                            Display="Dynamic"
                            ControlToValidate="fuFilename"
                            ValidationGroup="DocumentUpload"
                            runat="server" />
            </td>
        </tr>
        <tr>
            <td class="label" style="text-align:right;">Document Description:</td>
            <td class="normal">
                <asp:TextBox ID="txtDescription" runat="server" Width="405" MaxLength="50" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" Text="*"
                            ErrorMessage="Document Description is a required field"
                            Display="Dynamic"
                            ControlToValidate="txtDescription"
                            ValidationGroup="DocumentUpload"
                            runat="server" />
            </td>
        </tr>
        <tr>
            <td class="label" style="text-align:right;">Document Type:</td>
            <td class="normal">
                <asp:DropDownList ID="ddDocType" runat="server" Width="405"/>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" Text="*"
                            ErrorMessage="Document Type is a required field"
                            Display="Dynamic"
                            ControlToValidate="ddDocType"
                            ValidationGroup="DocumentUpload"
                            runat="server" />
            </td>
        </tr>
        <tr>
            <td class="label" style="vertical-align:top;text-align:right;">Customer Types:</td>
            <td class="normal">
                <asp:Label ID="lblSingleCustomer" Text="Specific Code:" runat="server" /><asp:TextBox ID="txtSingleCustomer" runat="server" Width="100px" /><br />
                <asp:CheckBoxList ID="cblCustomerTypes" runat="server" Width="405px" RepeatDirection="Horizontal" RepeatColumns="5" RepeatLayout="Table" CellPadding="10" CellSpacing="0" />
            </td>
        </tr>
        <tr>
            <td class="normal" colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <td class="normal" colspan="2"><asp:Label ID="lblError" runat="server" Text="" ForeColor="Red"/></td>
        </tr>
        <tr>
            <td class="normal" colspan="2">
                <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="BtnCancel_Click" CssClass="medium" />
                <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="BtnUpload_Click" CssClass="medium" />
            </td>
        </tr>
    </table>
</asp:Content>

它曾经可以正常工作,但是现在,并且在代码/设计没有明显变化的情况下,上传"和取消"按钮都不再起作用.

It USED to work fine, but now, and without apparent change to code/design, both the "Upload" and "Cancel" buttons no longer work.

在代码隐藏的Page_Load()方法中放置一个断点表明,仅在最初加载页面时才调用该断点,而在按下按钮时不调用该断点. 同样,在"BtnUpload_Click"事件中放置一个断点表明它从未被调用.

Putting a breakpoint in the codebehind's Page_Load() method shows that it is only called when the page is initially loaded, and not when the button is pressed. Similarly, putting a breakpoint in the "BtnUpload_Click" event shows it is never called.

现在这既不能在我自己的开发机器上,也不能在客户端服务器上(在从我的机器和服务器本身浏览到服务器页面时都不能使用).

This is now not working both on my own development machine AND on the client's server (both when browsing to the servers page from my machine AND from the server itself).

需要强调的是,在此工作正常到现在不工作之间,我90%确信代码方面没有任何变化.

It's important to stress that, between this working and it now not working, I am 90% sure nothing has changed in regards to the code.

任何帮助都将不胜感激,因为客户理所当然地感到焦虑-而且对于造成问题的原因我一无所知!

Any help would be greatly appreciated, as the customer is rightly anxious - and i'm clueless as to what's causing it!

编辑#1

以下是其中一个按钮的代码:

Here's the codebehind for one of the buttons:

protected void BtnUpload_Click(object sender, EventArgs e)
    {
        if (DataAccess.CheckIfMassUploadAlreadyExists(fuFilename.FileName))
        {
            lblError.Text = "A file with the specified name already exists within the system.";
            return;
        }
        else
        {
            try
            {
                UploadFile();
            }
            catch(Exception ex)
            {
                lblError.Text = ex.Message;// +"\nUsername:" + System.Web.HttpContext.Current.User.Identity.Name;
                return;
            }
        }
    }

.

推荐答案

这就是原因.这也是一个非常烦人的原因!

Here's the reason.. and it's a really annoying reason too!

这个:

<script type="text/javascript" src="../Help/HelpPopup.js" />

应该是这样:

<script type="text/javascript" src="../Help/HelpPopup.js"></script>


无论谁决定将脚本标签与其他HTML标签区别对待,都必须与贾斯汀·比伯(Justin Bieber)锁定在一个房间里.


Whoever decided the script tag needs to be treated differently to every other HTML tag, needs to be locked in a room with Justin Bieber.

这篇关于ASP.Net Button不提高回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆