Write a C# program to display selected date on calendar on label
Description:
Open Microsoft visual studio
File-> New -> Project -> visual c#
Program:
.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cal.aspx.cs" Inherits="cal" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="calnew" runat="server"></asp:Calendar>
<br />
<asp:Label ID="lbldate" runat="server" Text="Date"></asp:Label>
<br />
<br />
<asp:Button ID="btnshow" runat="server" onclick="btnshow_Click" Text="show" />
<br />
</div>
</form>
</body>
</html>
Description:
Open Microsoft visual studio
File-> New -> Project -> visual c#
Program:
.aspx file
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cal.aspx.cs" Inherits="cal" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Calendar ID="calnew" runat="server"></asp:Calendar>
<br />
<asp:Label ID="lbldate" runat="server" Text="Date"></asp:Label>
<br />
<br />
<asp:Button ID="btnshow" runat="server" onclick="btnshow_Click" Text="show" />
<br />
</div>
</form>
</body>
</html>
aspx.cs file
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
public partial class cal : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnshow_Click(object sender, EventArgs e)
{
lbldate.Text = calnew.SelectedDate.ToString();
}
}
demo:
Write a C# program to display selected date on calendar on label |
No comments:
Post a Comment