Here is the Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link href="FirstAsp.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" runat="server"> <div> <asp:Calendar ID="Calendar1" runat="server" ></asp:Calendar> <asp:Label ID="Label1" runat="server" Text="Enter your name"></asp:Label> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> <br /> <asp:Button ID="btnSubmit" runat="server" onclick="Button1_Click" Text="Submit" /> <asp:Label ID="lblResult" runat="server" Text=""></asp:Label> </div> </form> </body> </html>
Here is the Default.aspx.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string selectedDate = Calendar1.SelectedDate.ToShortDateString(); string name = txtName.Text; lblResult.Text= "thank you, " + name + ", The date you selected is " + selectedDate; if (Calendar1.SelectedDate.DayOfWeek.ToString() == "Saturday") { lblResult.CssClass = "weekend"; } else { lblResult.CssClass = "weekday"; } } }
Here is the firstAsp.css
body { } table tr th { font-weight:bold; background-color:Fuchsia; color:Lime; } .weekend { background-color:Green; } .weekday { background-color:White; }
No comments:
Post a Comment