0% found this document useful (0 votes)
100 views4 pages

Webform3 Aspx

This document contains code for an ASP.NET web application that allows users to add company information to a database. It includes web forms with text boxes and buttons to collect data for categories like company name, address, contact details. The code behind processes the form submission by inserting the data into a SQL database table using parameterized queries. Additionally, there is a login form to authenticate users before allowing access to the company addition forms.

Uploaded by

Parth Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views4 pages

Webform3 Aspx

This document contains code for an ASP.NET web application that allows users to add company information to a database. It includes web forms with text boxes and buttons to collect data for categories like company name, address, contact details. The code behind processes the form submission by inserting the data into a SQL database table using parameterized queries. Additionally, there is a login form to authenticate users before allowing access to the company addition forms.

Uploaded by

Parth Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Webform3.

aspx

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site3.Master"


CodeBehind="WebForm3.aspx.vb" Inherits="WebApplication1.WebForm3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table>
<tr>
<td>catagory:</td>
<td> <asp:TextBox ID="txtcat" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>shopname:</td>
<td> <asp:TextBox ID="txtname" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>address:</td>
<td> <asp:TextBox ID="txtadd" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>city:</td>
<td> <asp:TextBox ID="txtcity" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>state:</td>
<td><asp:TextBox ID="txtstate" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>contact:</td>
<td> <asp:TextBox ID="txtcontact" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>details:</td>
<td> <asp:TextBox ID="txtdetails" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>hrs of operation:</td>
<td><asp:TextBox ID="txthrs" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>yrest:</td>
<td> <asp:TextBox ID="txtyrest" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>clientid:</td>
<td> <asp:TextBox ID="txtclient" runat="server"> </asp:TextBox>
</td>
</tr>
<tr>
<td>Picture:</td>
<td> <asp:FileUpload ID="fupload1" runat="server" />
</td>
</tr>
<tr>
<td> <asp:Button ID="btnSubmit" runat="server" Text="Submit" /></td>
</tr>
</table>
</asp:Content>

Webform3.aspx.vb

Imports System.Data.SqlClient
Public Class WebForm3
Inherits System.Web.UI.Page
Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MY
PC\Desktop\Solution2\WebApplication1\App_Data\Database1.mdf;Integrated Security=True;User
Instance=True")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
cn.Open()
End Sub

Private Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles


btnSubmit.Click
Dim str As String
str = "insert into
tblshop(catagory,shopname,address,city,state,contact,details,hrsofoperation,yrest,clientid,pictur
e) values('" & txtcat.Text & "','" & txtname.Text & "','" & txtadd.Text & "','" & txtcity.Text & "','" &
txtstate.Text & "','" & txtcontact.Text & "','" & txtdetails.Text & "','" & txthrs.Text & "'," &
txtyrest.Text & "," & txtclient.Text & ",'" & fupload1.PostedFile.FileName & "',1)"
Dim cmd As New SqlCommand(str, cn)
cmd.ExecuteNonQuery()
MsgBox("inserted")
End Sub
End Class

Addcompany.aspx
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site3.Master"
CodeBehind="addcompany.aspx.vb" Inherits="WebApplication1.addcompany" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<table>
<tr>
<td>username</td>
<td><asp:TextBox ID="txtusername" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>password</td>
<td><asp:TextBox ID="txtpassword" runat="server"
TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td>emailid</td>
<td><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>fname</td>
<td><asp:TextBox ID="TextBox2" runat="server"
TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td>lname</td>
<td><asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>mobile</td>
<td><asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnsubmit" runat="server" Text="SUBMIT" />
</td>
</tr>
</table>
</div>
</asp:Content>

Addcompany.aspx.vb

Imports System.Data.SqlClient
Public Class addcompany
Inherits System.Web.UI.Page
Dim cn As New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\MY
PC\Desktop\Solution2\WebApplication1\App_Data\Database1.mdf;Integrated Security=True;User
Instance=True")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
If Session("username") = "" Then
Response.Redirect("userlogin.aspx")
End If
cn.Open()
txtpassword.Attributes("value") = txtpassword.Text
End Sub

Private Sub btnsubmit_Click(sender As Object, e As System.EventArgs) Handles


btnsubmit.Click
Dim str As String
str = "insert into tblclient(clientusername,clientpassword,emailid,fname,lname,mobile)
values('" & txtusername.Text & "','" & txtpassword.Text & "','" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "'," & TextBox4.Text & ")"
Dim cmd As New SqlCommand(str, cn)
cmd.ExecuteNonQuery()
End Sub
End Class

You might also like