<script runat="server">
protected void calEventDate_SelectionChanged(object sender, EventArgs e)
{
tbxdateofjoining.Text = calEventDate.SelectedDate.ToString("d");
}
</script>
<script type="text/javascript">
function displayCalendar() {
var datePicker = document.getElementById('datePicker');
datePicker.style.display = 'block';
}
</script>
<style type="text/css">
#datePicker
{
display:none;
position:absolute;
border:solid 2px black;
background-color:white;
}
.content
{
width:400px;
background-color:white;
margin:auto;
padding:10px;
}
html
{
background-color:white;
}
</style>
<asp:TextBox ID="tbxdateofjoining" runat="server"
style="z-index: 1; left: 555px; top: 394px; position: absolute" ></asp:TextBox>
<img alt="" src="Images/calendar-schedulehs-thumb.png" onclick="displayCalendar()"
style="z-index: 1; left: 714px; top: 394px; position: absolute; height: 20px; width: 20px;" />
<div id="datePicker">
<asp:Calendar id="calEventDate" OnSelectionChanged="calEventDate_SelectionChanged" Runat="server" style="z-index: 1; left: 715px; top: 251px; position: absolute; height: 17px" />
</div>
ON ADD BUTTON CLICK.
protected void btnadd_Click(object sender, EventArgs e)
{
String connectionString = @"Data Source=TECH\SQLEXPRESS2008;Initial Catalog=employee;Integrated Security=True";
SqlConnection thisConnection = new SqlConnection(connectionString);
try
{
thisConnection.Open();
String thisQuery = "INSERT INTO EmployeeDetails(FirstName,MiddleName,LastName,Address,Telephone,MobileNo,DateOfBirth,Department,Designation,DateOfJoining,BloodGroup) VALUES ('" + tbxfirstname.Text + "', '" + tbxmiddlename.Text + "', '" + tbxlastname.Text + "', '" + tbxaddress.Text + "', '" + tbxtelephoneno.Text + "', '" + tbxmobileno.Text + "', '" + tbxdateofbirth.Text + "','" + tbxdepartment.Text + "','" + tbxdesignation.Text + "','" + tbxdateofjoining.Text + "','" + tbxbloodgroup.Text + "')";
SqlCommand thisCommand = new SqlCommand(thisQuery, thisConnection);
thisCommand.ExecuteNonQuery();
lblmessage.Text = "Record Added Successfully !!!";
thisConnection.Close();
}
catch (SqlException exp)
{
lblmessage.Text = exp.Message;
Console.WriteLine(exp.Message);
}
}