Critical Developers

Programmers Knowledge Base

Validate File Upload using REGEX / RegularExpressionValidator

Validate File Upload using RegularExpressionValidator

GUI
<asp:FileUpload id="FileUploadFH" runat="server"></asp:FileUpload>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="FileUploadFH"
                    Display="Dynamic" ErrorMessage="Only .pdf,.doc,.docx,.xls,.xlsx,.rtf are allowed" ValidationExpression="(.*?)\.(Pdf|doc|docx|xls|xlsx|rtf)$"></asp:RegularExpressionValidator>

Code Behind
 if (FileUploadFH.HasFile)
   {
    FileUploadFH.SaveAs(Server.MapPath("../pdf/French/abc.doc") );
   }

Read and Process 835 ERA (Electronic Remittance Advice) using ASP.Net and SQL Server

How to read EDI file 835 in asp.net and sql server -

Find the below algorithm to read and process ERA 835 file:-

1) Upload 835 file and convert it to Excel XML or CSV using code here.

2) Convert XML or CSV to a DataTable.

3) Import the DataTable to a Sql Table (e.g. tblERA835ImportedData) using Sql BCP.

4) Write a stored procedure to insert credit transaction entry (you can use cursor or while loop in sql)

Note:- Validate 835 file Before uploading. (Just check the file has ISA segment with 106 characters in length)