1

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.

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).

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!


EDIT #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;
            }
        }
    }

.

Sk93
  • 3,676
  • 3
  • 37
  • 67
  • 1
    what does the code behind look like for the button events? – Josh Dec 01 '10 at 11:55
  • please view the HTML source of the page (right click --> view source) and post here the relevant part of the buttons.. curious to see how the final HTML looks like maybe it will give some hint. – Shadow The GPT Wizard Dec 01 '10 at 12:36
  • @Shadow Wizard - it did indeed give a hint.. or rather, Chrome's built-in developer tools. – Sk93 Dec 01 '10 at 13:56

5 Answers5

15

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

THIS:

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

Should be THIS:

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

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.

Sk93
  • 3,676
  • 3
  • 37
  • 67
  • 1
    ah, nice catch. I found a related question for your edification: http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work – Josh Dec 01 '10 at 15:53
6

First off all you should check your Validators and perhabs, comment them out for a test.

Is it possible that there are JavaScript-Errors showing on your page? An ASP-Button is calling a JavaScript-Funktion (WebForm_DoPostBackWithOptions), if there is a JavaScript-Error "before" this line, sometimes you can't press a button.

EvilMM
  • 901
  • 4
  • 9
3

At the risk of being down voted for posting an answer to the title question which does not appear to be the OP's problem... I will offer this suggestion which fixed my similar problem:

<body  background="images/GlobeBg.png" bgproperties="fixed">
</body>

Problem is, 'bgproperties' is NOT a valid attribute name even though some guys on the internet said it was. Other than an unnoticed squiggle underline in VWD 2008 Express, no error was emitted and the page otherwise looked normal. Simply, the update button and other input controls didn't work.

B H
  • 1,730
  • 18
  • 24
3

apparently a client side "return false" is preventing the callback, this could be one of two reasons:

1-the validators always return not valid
2-some client script being called on the button returns false;
Ali Tarhini
  • 5,278
  • 6
  • 41
  • 66
  • Looking at the code, I cannot work out why the validators would be returning not valid, if text exists in all three required fields (which is does). There's also no javascript being called when the button is pressed.. – Sk93 Dec 01 '10 at 12:02
  • Also, how do you know "return false" is occurring? Is there some tool you can run to diagnose that? – Sk93 Dec 01 '10 at 12:03
  • only return false prevents a postback from happening – Ali Tarhini Dec 01 '10 at 12:04
  • 1
    to test this you could add CausesValidation="false" to the button markup – Josh Dec 01 '10 at 12:08
  • 1
    interestingly, neither removing the validators, nor adding "CausesValidation" proved helpful in this instance - But thank you both for the help! – Sk93 Dec 01 '10 at 13:55
  • im out of ideas for the moment,sorry :) – Ali Tarhini Dec 01 '10 at 13:56
  • It's ok - I've found the solution, and posted my answer below... just can't accept it for two days :/ – Sk93 Dec 01 '10 at 14:48
  • I was adding javascript to disable an ASP.NET button from being clicked twice. I had a 'return false' which prevented auto-post backs. Removing the 'return false' sorted the issue. Thanks. – robnick Sep 05 '18 at 00:52
0

The cause for this for me was that a validator on another view in the same page was being fired, due to it being apart of the same validation group.So this prevented the post back.