
Creating add new record aspx.net web application page using textbox validation RegularExpressionValidator and RequiredFieldValidator fileupload control with datagrid and label uploaded file link

" & _ "File Size: " & _ FileUpload1.PostedFile.ContentLength & " kb
" & _ "Content type: " & _ FileUpload1.PostedFile.ContentType Catch ex As Exception Label60.Text = "ERROR: " & ex.Message.ToString() End Try Else Label60.Text = "You have not specified a valid file [.pdf], So, your document uploading have failure, Please submit this document at office in person." End If Dim doc As String = " " & FileUpload1.FileName & "" sql = "insert into JANTA(Representation_Receiving_Date, Applicant_Name, Father_or_Husband_Name, Address, Post_Office, Police_Station, Sub_Division, Contact_No, Complain_Description, Applicant_document) values ('" & Now() & "', '" & TextBox2.Text & "', '" & TextBox3.Text & "', '" & TextBox4.Text & "', '" & TextBox5.Text & "', '" & TextBox6.Text & "', '" & TextBox7.Text & "', '" & TextBox8.Text & "', '" & TextBox9.Text & "', '" & doc & "')" If conn.State = Data.ConnectionState.Closed Then conn.Open() adp = New OleDbDataAdapter adp.InsertCommand = New OleDbCommand(sql, conn) adp.InsertCommand.ExecuteNonQuery() TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox5.Text = "" TextBox6.Text = "" TextBox7.Text = "" TextBox8.Text = "" TextBox9.Text = "" Page_Load() End If End If End Sub Sub back(ByVal sender As Object, ByVal e As EventArgs) Response.Redirect("login.aspx") End Sub 'Sub upload1(ByVal sender As Object, ByVal e As EventArgs) 'If FileUpload1.HasFile Then 'Try 'FileUpload1.SaveAs("C:\Inetpub\wwwroot\JA\images\" & _ ' FileUpload1.FileName) ' Label6.Text = "File name: " & _ ' FileUpload1.PostedFile.FileName & "
" & _ '"File Size: " & _ ' FileUpload1.PostedFile.ContentLength & " kb
" & _ '"Content type: " & _ ' FileUpload1.PostedFile.ContentType 'Catch ex As Exception ' Label6.Text = "ERROR: " & ex.Message.ToString() 'End Try 'Else ' Label6.Text = "You have not specified a file." ' End If ' End Sub
here html code : TextBox ID="TextBox2" runat="server" Width="224px" asp:TextBox asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" Display="Dynamic" ErrorMessage="should not be blank !!" asp:RequiredFieldValidator TextBox ID="TextBox4" runat="server" TextMode="MultiLine" Width="224px" asp:TextBox asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox4" Display="Dynamic" ErrorMessage="should not be blank !!" asp:RequiredFieldValidator
Label ID="Label8" runat="server" Font-Bold="True" ForeColor="White" Text="Mobile No.:" Width="120px" asp:Label asp:TextBox ID="TextBox8" runat="server" Width="224px" asp:TextBox asp:RegularExpressionValidator Display = "Dynamic" ControlToValidate = "TextBox8" ID="RegularExpressionValidator3" ValidationExpression = "^[\s\S]{10,10}$" runat="server" ErrorMessage="Minimum and Maximum 10 characters for mobile number required." asp:RegularExpressionValidator
asp:Label ID="Label60" runat="server" Style="z-index: 101; left: 763px; position: absolute; top: 376px" Width="305px" Height="213px" ForeColor="White" asp:Label
asp:FileUpload ID="FileUpload1" runat="server" Style="z-index: 102; left: 820px; position: absolute; top: 658px"
asp:Label ID="Label13" runat="server" Font-Bold="True" Style="z-index: 105; left: 609px; position: absolute; top: 629px" Text='Please upload only ".pdf" document of size less then 4 mb otherwise documnet upload will not happen, and skiped:' Width="192px" ForeColor="White" Height="63px"asp:Label .......................... after add record successfully :






" & _ "File Size: " & _ FileUpload1.PostedFile.ContentLength & " kb
" & _ "Content type: " & _ FileUpload1.PostedFile.ContentType Catch ex As Exception Label60.Text = "ERROR: " & ex.Message.ToString() End Try Else Label60.Text = "You have not specified a valid file [.pdf], So, your document uploading have failure, Please submit this document at office in person." End If Dim doc As String = " " & FileUpload1.FileName & "" str = "update JANTA set Representation_Receiving_Date='" & TextBox1.Text & "', Applicant_Name='" & TextBox2.Text & "', Father_or_Husband_Name='" & TextBox3.Text & "', Address='" & TextBox4.Text & "', Post_Office='" & TextBox5.Text & "', Police_Station='" & TextBox6.Text & "', Sub_Division='" & TextBox7.Text & "', Contact_No=" & TextBox8.Text & ", Complain_Description='" & TextBox9.Text & "', Applicant_Document='" & doc & "' where Ticket_No = " & TextBox00.Text If TextBox0.Text = "pass code" Then Dim adp As New OleDbDataAdapter(str, conn) adp.Fill(dset, "JANTA") Response.Redirect("edit.aspx") conn.Close() Else TextBox0.Text = "wrong password" End If as well as i provide find button for code - Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim st As String st = "select * from JANTA where Ticket_No=" & TextBox00.Text Dim adp As New OleDbDataAdapter(st, conn) Dim dset As New Data.DataSet adp.Fill(dset, "JANTA") TextBox1.Text = dset.Tables(0).Rows(0).Item(0) TextBox2.Text = dset.Tables(0).Rows(0).Item(2) TextBox3.Text = dset.Tables(0).Rows(0).Item(3) TextBox4.Text = dset.Tables(0).Rows(0).Item(4) TextBox5.Text = dset.Tables(0).Rows(0).Item(5) TextBox6.Text = dset.Tables(0).Rows(0).Item(6) TextBox7.Text = dset.Tables(0).Rows(0).Item(7) TextBox8.Text = dset.Tables(0).Rows(0).Item(8) TextBox9.Text = dset.Tables(0).Rows(0).Item(9) 'TextBox10.Text = dset.Tables(0).Rows(0).Item(22) Label14.Text = dset.Tables(0).Rows(0).Item(22) conn.Close() in loading tiket no. use : Sub Page_Load() Dim conn1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & """" & "C:\Inetpub\wwwroot\JA\mnp.mdb" & """") Dim adp1 As New OleDbDataAdapter("select max(Ticket_no) from JANTA", conn) Dim dset1 As New Data.DataSet adp1.Fill(dset1, "JANTA") TextBox1.Text = Now() Label20.Text = "Last Ticket No. is: " & dset1.Tables(0).Rows(0).Item(0) End Sub



No comments:
Post a Comment