تقييمات الطلاب
( 5 من 5 )
١ تقييمات
فيديو شرح Adding custom events to asp net composite custom control Part 116 ضمن كورس ASP.net شرح قناة kudvenkat، الفديو رقم 116 مجانى معتمد اونلاين
Text version of the video
http://csharp-video-tutorials.blogspot.com/2013/01/adding-custom-events-to-aspnet.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-116-adding-custom-events-to-aspnet.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 this video we will discuss about adding custom event to the asp.net composite custom calendar control that we have been working with from Parts 112 to 115. Please watch Parts 112 to 115 from the asp.net video tutorial before proceeding with this video. ASP.NET video tutorial link is shown below.
http://www.youtube.com/playlist?listPL6n9fhu94yhXQS_p1i-HLIftB9Y7Vnxlo
We have discussed about adding custom events to user controls in Parts 106 to 108. You can watch these videos from the asp.net video tutorial. Adding custom events to a composite control is similar to adding events to user controls.
There are 5 simple steps to add "DateSelected" custom event to composite custom calendar control
Step 1: Create "DateSelectedEventArgs" that will contain event data
public class DateSelectedEventArgs : EventArgs
{
private DateTime _selectedDate;
public DateSelectedEventArgs(DateTime selectedDate)
{
this._selectedDate selectedDate;
}
public DateTime SelectedDate
{
get
{
return this._selectedDate;
}
}
}
Step 2: Create "DateSelectedEventHandler" delegate
public delegate void DateSelectedEventHandler(object sender, DateSelectedEventArgs e);
Step 3: Create "DateSelected" event.
public event DateSelectedEventHandler DateSelected;
Step 4: Create a protected virtual method to raise the event.
protected virtual void OnDateSelection(DateSelectedEventArgs e)
{
if (DateSelected ! null)
{
DateSelected(this, e);
}
}
Step 5: Finally raise the event, when the date selection in the calendar changes.
DateSelectedEventArgs dateSelectedEventData new DateSelectedEventArgs(calendar.SelectedDate);
OnDateSelection(dateSelectedEventData);
Complete custom calendar code can be found at the link below
http://csharp-video-tutorials.blogspot.com/2013/01/adding-custom-events-to-aspnet.html
Build the CustomControls project. In an asp.net web application add a reference to the CustomCalendar control. Drag and drop the CustomCalendar control on a webform. Right click on the control and select properties. In the properties window, click on the events icon. Notice that, the event "DateSelected" is displayed.
Double click on the "DateSelected" event. This should automatically generate an event handler method. Implement the event handler method as shown below.
protected void CustomCalendar1_DateSelected(object sender, CustomControls.DateSelectedEventArgs e)
{
Response.Write(e.SelectedDate.ToShortDateString());
}
Please run the project, and test.