Вот HTML-разметка:
Код: Выделить всё
.parent{
align-items: center;
border: 1px solid black;
display: contents;
justify-content: center;
height: 150px;
width:contain;
}
.margin {
border: 1px solid black;
margin-bottom: 2px;
}
.button {
background-color: lightblue;
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
.div {
height: 5px;
align-items: center;
}
First Name:
Last Name:
Address:
Contact No.:
Date:
Time:
Age:
Status: StableCritical
Код: Выделить всё
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.Xml.Linq;
namespace Formtask
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void btn(object sender, EventArgs e)
{
string connectionString = @"Data Source=LAPTOP-VN6JLQTP\SQLEXPRESS;Initial Catalog=webform;Integrated Security=True;Trust Server Certificate=True ";
using (SqlConnection con = new SqlConnection(connectionString))
{
string query = "INSERT INTO datain (FirstName, LastName, Address, ContactNo, Date, Time, Age, Status) VALUES (@FirstName, @LastName, @Address, @ContactNo, @Date, @Time, @Age, @Status)";
using (SqlCommand cmd = new SqlCommand(query, con))
{
cmd.Parameters.AddWithValue("@FirstName", Request.Form["fname"]);
cmd.Parameters.AddWithValue("@LastName", Request.Form["lname"]);
cmd.Parameters.AddWithValue("@Address", Request.Form["add"]);
cmd.Parameters.AddWithValue("@ContactNo", Request.Form["ph"]);
cmd.Parameters.AddWithValue("@Date", Request.Form["date"]);
cmd.Parameters.AddWithValue("@Time", Request.Form["time"]);
cmd.Parameters.AddWithValue("@Age", Request.Form["age"]);
cmd.Parameters.AddWithValue("@Status", Request.Form["st"]);
con.Open();
cmd.ExecuteNonQuery();
}
}
// Optionally, you can redirect the user to another page after submission
// Response.Redirect("SuccessPage.aspx");
}
}
}
Код: Выделить всё
CREATE DATABASE webform;
CREATE TABLE datain
(
ID INT PRIMARY KEY IDENTITY(1,1),
PatientRegistrationNo NVARCHAR(50)
DEFAULT CONCAT('REG', REPLACE(CONVERT(NVARCHAR(36), NEWID()), '-', '')),
FirstName NVARCHAR(50),
LastName NVARCHAR(50),
Address NVARCHAR(100),
ContactNo NVARCHAR(20),
Date DATE,
Time TIME,
Age INT,
Status NVARCHAR(50)
);
SELECT * FROM datain;
Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/785 ... ng-asp-net