ASP NET Programs CSharp Updated
ASP NET Programs CSharp Updated
a) Display "Hello World!" and a button that changes color on mouse hover:
File: Default.aspx
--------------------------------------------------
Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style>
.hoverButton {
background-color: green;
color: white;
border: none;
cursor: pointer;
.hoverButton:hover {
background-color: yellow;
color: black;
</style>
</head>
<body>
</div>
</form>
</body>
</html>
File: Default.aspx.cs
--------------------------------------------------
using System;
}
b) Display web controls: Centered button, label, and checkbox
File: WebControls.aspx
--------------------------------------------------
Inherits="WebControls" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Web Controls</title>
<style>
.centerDiv {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 90vh;
</style>
</head>
<body>
<div class="centerDiv">
</div>
</form>
</body>
</html>
File: WebControls.aspx.cs
--------------------------------------------------
using System;
}
Program 2: User Login Form using ASP.NET, ADO.NET & MySQL
USE userdb;
User_Name VARCHAR(50),
Password VARCHAR(50)
);
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login Page</title>
</head>
<body>
/>
/><br />
</div>
</form>
</body>
</html>
Code-behind (Login.aspx.cs):
using System;
using System.Data;
using MySql.Data.MySqlClient;
con.Open();
cmd.Parameters.AddWithValue("@uname", txtUser.Text);
cmd.Parameters.AddWithValue("@pwd", txtPass.Text);
if (reader.HasRows)
else