Asp DHARMM
Asp DHARMM
Asp DHARMM
Que-1. Create a web page with following controls and display inputted/selected
values: Label, Text Box, Radio Button, Radio Button List, Checkbox, Check
boxlist, Calendar, Drop Down List, List box and File Upload Control.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
</head>
<body>
<form id="form1" runat="server">
<div>
<!-- Label and TextBox -->
ASP.NET 1
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
ASP.NET 2
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
<asp:ListItem Text="Option 2" Value="2"></asp:ListItem>
<asp:ListItem Text="Option 3" Value="3"></asp:ListItem>
</asp:ListBox>
<br /><br />
</div>
<div>
<asp:Label ID="ResultLabel" runat="server" Text=""></asp:Label>
</div>
</form>
</body>
</html>
OUTPUT:
ASP.NET 3
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Que-2. Use session, query string, view state, cookies and application variable
using appropriate examples (Set and Get) Hint: Design Login form.
ASP.NET 4
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Session("uname") =
TextBox1.Text
Query string:
View state:
Partial Class viewState
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If ViewState("c1") Is
Nothing Then
ViewState("c1") = 0 Else
ViewState("c1") += 1 End If
ASP.NET 5
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Label1.Text = ViewState("c1") End Sub End
Class
Cookies:
Partial Class cookies
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Response.Cookies("c1")("uname") = TextBox1.Text Response.Cookies("c1")("pass")
= TextBox2.Text
Response.Cookies("c1").Expires = Date.Now.AddSeconds(30)
End Sub
Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Label1.Text
= Request.Cookies("c1")("uname")
Label2.Text = Request.Cookies("c1")("pass") End
Sub
End Class
Application:
Partial Class application Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If Application("c1")
Is Nothing Then
Application("c1") = 0 Else
Application("c1") += 1 End If
Label1.Text = Application("c1")
End Sub
End Class
ASP.NET 6
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Que-3. Develop a web form for Cricket Player entry (Only HTML/ASPX Code)
using appropriate master page, header, footer and data base table.
[Hint:Player_Master (P_Id, P_Name, P_Password, P_Gender, P_ContactNo,
P_Email, P_Address, P_RegDate, P_Type)].
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Cricket Player Registration</title>
<header class="header">
<div class="container">
<h1>Cricket Club</h1>
<nav>
<ul>
<li><a href="Home.aspx">Home</a></li>
<li><a href="Regi.aspx">Registration</a></li>
</ul>
ASP.NET 7
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
</nav>
</div>
</header>
<div class="content">
<p>
<br />
</p>
</asp:ContentPlaceHolder>
</div>
class="container">
<p>© 2024 Cricket Club. All rights reserved.</p>
</div>
</footer>
</form>
</body>
</html>
OUTPUT:
ASP.NET 8
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
DataBase:
CREATE TABLE [dbo].[Player_Master] (
[P_Id] INT IDENTITY (1, 1) NOT NULL, [P_name] NVARCHAR (50) NULL,
[P_contactno] NUMERIC (18) NULL, [P_emailid] NVARCHAR (50) NULL, [P_address] NVARCHAR (50) NULL,
[P_regdate] NVARCHAR (50) NULL, [P_type] NVARCHAR (50) NULL, PRIMARY KEY CLUSTERED ([P_Id] ASC)
);
ASP.NET 9
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Que-4. Apply validations in the form developed in the above Question No. 3.
ASP.NET 10
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
ASP.NET 11
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
OUTPUT:
ASP.NET 12
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Que-5. Develop code for insert, update, search and delete facilities using form
developed in the above Question No. 3 using GridView Control or any other
control.
ASP.NET 13
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
OUTPUT:
ASP.NET 14
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
Inherits System.Web.UI.Page
ASP.NET 15
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
cmd.CommandText = qry
cmd.Connection = cn
cmd.ExecuteNonQuery()
cn.Close()
Catch ex As Exception lblMessage.Text = "An error occurred: " & ex.Message End
Try
Response.Redirect("Registration.aspx") End Sub
Response.Redirect("Registration.aspx")
Try
End Sub End Class
ASP.NET 16
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
OUTPUT:
Skin.skin(File):
<asp:TextBox runat="server" BackColor="Fuchsia" BorderColor="#003300"
BorderStyle="Dotted" BorderWidth="5px" ForeColor="#003300"></asp:TextBox> Web.config:
<pages theme ="skinfile"></pages>
Registration File:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="Registration.aspx.vb" Inherits="_Default" Theme ="SkinFile"%>
<td> </td>
</tr>
<tr>
ASP.NET 17
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
</td>
<td> </td>
</tr>
<tr>
</td>
<td> </td>
</tr>
<tr>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
ASP.NET 18
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
</td>
<td> </td>
</tr>
<tr>
</td>
<td> </td>
</tr>
<tr>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
ASP.NET 19
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
</tr>
<tr>
</td>
<td> </td>
</tr>
<tr>
<Columns>
</Columns>
</asp:GridView>
ASP.NET 20
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
<DeleteParameters>
<asp:Parameter Name="P_Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="P_name" Type="String" />
</UpdateParameters>
ASP.NET 21
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
</asp:SqlDataSource>
</td>
<td> </td>
</tr>
</table>
</asp:Content>
OUTPUT:
Password Handling:
Imports System.Security.Cryptography
Imports System.Text
Public Function HashPassword(ByVal password As String) As String
Using sha256 As SHA256 = SHA256.Create()
Dim bytes As Byte() = sha256.ComputeHash(Encoding.UTF8.GetBytes(password))
Return BitConverter.ToString(bytes).Replace("-", "").ToLower() End Using
End Function
ASP.NET 22
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
lblMessage.Text = HttpUtility.HtmlEncode(ex.Message)
Use HTTPS:
<system.webServer>
<rewrite>
<rules>
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Security Headers:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Content-Type-Options" value="nosniff" />
<add name="X-Frame-Options" value="DENY" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
</system.webServer>
Error Handling:
ASP.NET 23
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
<system.web>
<customErrors mode="On" defaultRedirect="ErrorPage.aspx">
<error statusCode="404" redirect="NotFound.aspx" />
<error statusCode="500" redirect="ServerError.aspx" />
</customErrors>
</system.web>
HTML:
<asp:HiddenField ID=" RequestVerificationToken" runat="server" Value="<%=
ViewState[" RequestVerificationToken"] %>" />
VB:
Dim token As String = Request.Form(" RequestVerificationToken")
If token Is Nothing OrElse token <> ViewState(" RequestVerificationToken").ToString() Then Throw
New HttpException(403, "CSRF validation failed.")
End If
MathService.aspx:
ASP.NET 24
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
<WebMethod()> _
Public Function Subtract(ByVal a As Integer, ByVal b As Integer) As Integer Return
a-b
End Function End
Class
Default.aspx:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Math Operations</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtNumber1" runat="server" />
<asp:TextBox ID="txtNumber2" runat="server" />
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" />
<asp:Button ID="btnSubtract" runat="server" Text="Subtract" OnClick="btnSubtract_Click" /> <br
/>
<asp:Label ID="lblResult" runat="server" Text="" /> </div>
</form>
</body>
</html>
Default.aspx.vb:
Imports System.Web.UI
Imports YourProject.MathServiceReference ' Adjust namespace as needed
Public Class Default
Inherits System.Web.UI.Page
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs)Try Dim
number1 As Integer = Convert.ToInt32(txtNumber1.Text)
Dim number2 As Integer = Convert.ToInt32(txtNumber2.Text)
ASP.NET 25
TY BCA - B ROLL NO:2461124 DHARM J JASOLIYA
OUTPUT:
ASP.NET 26