Solving the problems of asp net composite custom calendar control Part 115

  • دعنا نشارك هذا :
ترتيب الدرس : 115
المدة : 00:23:43
التحكم :
Text version of the video
http://csharp-video-tutorials.blogspot.com/2013/01/solving-problems-of-aspnet-composite.html

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation1

Slides
http://csharp-video-tutorials.blogspot.com/2013/08/part-115-solving-problems-of-composite.html

All ASP .NET Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-aspnet-video-tutorial.html

All ASP .NET Slides
http://csharp-video-tutorials.blogspot.com/p/aspnet-slides.html

All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view1&sortdd

All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists

In Parts 112 to 114in asp.net video series, we discussed about the basics of composite custom controls in asp.net. Please watch Parts 112 to 114, before proceeding with this video. Use the link below to access asp.net video tutorial
http://www.youtube.com/playlist?listPL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo

In this video we will discuss about
1. Hiding the calendar control, when the CustomCalendar control is first loaded
2. Displaying and hiding the calendar, when the image button is clicked
3. Populating the textbox control, with a date that is selected from the calendar
4. Retrieving the selected date from the CustomCalendar control on a webform.

Hiding the calendar control, when the CustomCalendar control is first loaded:
To hide the calendar set calendar.Visiblefalse in CreateChildControls() method in CustomCalendar.cs file

Displaying and hiding the calendar, when the image button is clicked:
To toggle the visibility of the calendar object, first register an event handler method, with the click event of the image button in CreateChildControls() method as shown below.
imageButton.Click + new ImageClickEventHandler(imageButton_Click);

Provde the implementation for imageButton_Click() event handler method as shown below.
void imageButton_Click(object sender, ImageClickEventArgs e)
{
// If the calendar is visible, make it invisible
if (calendar.Visible)
{
calendar.Visiblefalse;
}
// If the calendar is invisible, make it visible
else
{
calendar.Visibletrue;
// if the user has not already selected a date, then set
// set the VisibleDate of the calendar to today's date
if (string.IsNullOrEmpty(textBox.Text))
{
calendar.VisibleDateDateTime.Today;
}
// if the user has already selected a date, then set
// set the VisibleDate of the calendar to the selected date
// by retrieving it from the textbox
else
{
DateTime outputDateTime.Today;
bool isDateTimeConverionSuccessfulDateTime.TryParse(textBox.Text, out output);
calendar.VisibleDateoutput;
}
}
}

Populating the textbox control, with a date that is selected from the calendar:
First register an event handler method, with the "SelectionChanged" event of the calendar in CreateChildControls() method as shown below.
calendar.SelectionChanged + new EventHandler(calendar_SelectionChanged);

Provde the implementation for calendar_SelectionChanged() event handler method as shown below.
void calendar_SelectionChanged(object sender, EventArgs e)
{
// Populate the text box wit the selected date
textBox.Textcalendar.SelectedDate.ToShortDateString();
// Make the calendar invisible
calendar.Visiblefalse;
}

Retrieving the selected date from the CustomCalendar control on a webform:
To retrieve the selected date from the CustomCalendar control, add SelectedDate property to the CustomCalendar class as shown below.
[Category("Appearance")]
[Description("Gets or sets the selected date of custom calendar control")]
public DateTime SelectedDate
{
get
{
EnsureChildControls();
return string.IsNullOrEmpty(textBox.Text) ? DateTime.MinValue : Convert.ToDateTime(textBox.Text);
}

set
{
if (value ! null)
{
EnsureChildControls();
textBox.Textvalue.ToShortDateString();
}
else
{
EnsureChildControls();
textBox.Text"";
}
}
}

Complete code of CustomCalendar control can be found at the following link
http://csharp-video-tutorials.blogspot.com/2013/01/solving-problems-of-aspnet-composite.html

Pls build CustomControls project, and add a reference to CustomCalendar in asp.net web application for testing. Drag and drop the CustomCalendar control and a button onto the webform.

Double click the button control to generate the click event handler.

سيتم تفعيل التعليقات قريبا

y
Sep 23, 2020 07:32:26
youtube