Problem with multifile and regularexpression validator

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with multifile and regularexpression validator

Guest-988
I have a multifile upload control on my page with a regularexpressionvalidator to only allow the upload of .xls files.  When I click on my submit button client side validation occurs if i have an incorrect file in the queue for upload, but if I have the correct files ie only .xls files the file upload does not start.  The Button_Click server side event does not fire at all.  Any idea as to why?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Dean Brettle
Administrator
Please post your aspx file so that I can see the regex you are using.  Also, what version of NeatUpload are you using?
--Dean
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Guest-988
Im using version 1.3.14. 

<%@ Page Language="C#" MasterPageFile="~/Details.master" AutoEventWireup="true" Inherits="MeterProfiles" Title="New Meter Profiles" Codebehind="MeterProfiles.aspx.cs" %>
<%@ Register Assembly="Brettle.Web.NeatUpload" Namespace="Brettle.Web.NeatUpload" TagPrefix="Upload" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script language="javascript" type="text/javascript">

NeatUploadMultiFile.prototype.OnFileQueued = function (file) {
    var numf = this;

    var span = document.createElement('span');
    span.setAttribute('style', 'TEXT-ALIGN: left');

    var link = document.createElement('a');
    link.setAttribute('href', '#');
    link.onclick = function () {
        file.Delete();
        span.parentNode.removeChild(span);
        return false;
    };
    link.appendChild(document.createTextNode('Remove'));
    span.appendChild(link);
    var index = file.name.lastIndexOf('\\');
    var fileName = file.name.substring(index + 1);
    span.appendChild(document.createTextNode(' ' + fileName));
    span.appendChild(document.createElement('br'));
    span.appendChild(document.createElement('br'));
    var fqc = numf.GetFileQueueControl();
    fqc.appendChild(span);
};
</script>

<table id="maintbl" class="table_con" width="100%">
    <tr>
        <td align="center" colspan="4" valign="top">
            &nbsp;<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Select File/s" Width="165px" Font-Size="Small" ForeColor="Black"></asp:Label>
            <br />
        </td>
    </tr>
    <tr>
        <td align="center" colspan="4" valign="top">
             <Upload:MultiFile ID="MultiFile1" runat="server"
                 FlashFilterExtensions="*.xls" UseFlashIfAvailable="True"
                
                >
            <input id="Button1" type="button" value="Select Files..." /></Upload:MultiFile>
            <br />
           &nbsp;<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
                 runat="server" ControlToValidate="MultiFile1"
                 ErrorMessage="Only files with a .xls extension may be uploaded. Please remove the incorrect files from the above list before submitting again."
                
                 ValidationExpression="(([^.;]*[.])+(xls|XLS); *)*(([^.;]*[.])+(xls|XLS))?$"></asp:RegularExpressionValidator>
             <br />
        </td>
      
    </tr>
    <tr>
        <td colspan="4">
        <Upload:ProgressBar ID="ProgressBar1" runat="server" Width="500px"></Upload:ProgressBar>
        </td>
    </tr>
    <tr>
        <td colspan="4" align="center">
            <asp:Button ID="btnSubmit" runat="server" Text="Submit"  />
            <asp:Button ID="btnCancel" runat="server" Text="Cancel"
                CausesValidation="False" />&nbsp;
        </td>
    </tr>
</table>
</asp:Content>

Im guessing my validationexpression is wrong, i modified it from the Demo.aspx page that came with the NeatUpload1.3.14 download.  Clearly I have no idea how regular expression work.  Any help with that would be greatly appreciated.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Guest-988
my server side code looks like this

 protected void Page_Load(object sender, EventArgs e)
    {
            btnSubmit.Click += new System.EventHandler(this.Button_Clicked);
            ProgressBar1.AddTrigger(btnSubmit);
    }

 private void Button_Clicked(object sender, EventArgs e)
    {
        if (!this.IsValid)
        {
            return;
        }

        if (MultiFile1.Files.Length > 0)
        {
            foreach (UploadedFile file in MultiFile1.Files)
            {
               //file processing done here
            }
        }
    }

The strange thing is I tested the validation expression and the exact other settings i use on my page for the regularExpressionValidator in the Demo.aspx page that came with the NeatUpload1.3.14 download and it works fine and the upload begins.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Dean Brettle
Administrator
I tried to reproduce the problem, but it works fine for me.  The only difference is that I used my own master page since you didn't post your Details.master.  If you don't use the master page, does the problem go away?  If so, please post Details.master.

Also, if you copy Demo.aspx and Demo.aspx.cs into your app, can you upload using that copy of Demo.aspx?

--Dean
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Guest-988
Sorry for the late reply.

I did copy Demo.aspx and Demo.aspx.cs into my project and they worked fine.

I mailed u a project that reproduces the problem I'm having.

I hope u can figure out what the problem is!
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Dean Brettle
Administrator
You have a RequiredFieldValidator for a field called txtComment and that field is being hidden by something else you are doing on the page.  The form is not submitting because there is no comment was supplied, but you can't see that because the field is hidden.  This has nothing to do with NeatUpload.
Reply | Threaded
Open this post in threaded view
|

Re: Problem with multifile and regularexpression validator

Guest-988
Ah ok, thanks very much for your time and effort!  Much appreciated!