http://csharp-video-tutorials.blogspo...
Slides
http://csharp-video-tutorials.blogspo...
All ASP .NET Text Articles
http://csharp-video-tutorials.blogspo...
All ASP .NET Slides
http://csharp-video-tutorials.blogspo...
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatAr...
In this video we will discuss about
1. Adding events to UserControls
2. Events and delegates
Most people feel "events and delegates" are complex and difficult to understand. Events and delegates are not that complex to understand, if the basics are right. To get the most out of this video, I strongly recomend to watch parts 36, 37 , 38 and 39 from C# Video series, and parts 104 and 105 from asp.net video series, before proceeding with this video.
C# Video tutorial link
http://www.youtube.com/playlist?list=...
ASP.NET tutorial link
http://www.youtube.com/playlist?list=...
Very important points to keep in mind, when understanding "Events and Delegates"
1. Delegates are function pointers, and their syntax is very similar to that of a function.
2. Events are variables of type delegates with an event keyword.
If these points are not clear at the moment, don't worry, they will be much clear as we progress.
At the moment, the CalendarUserControl does not have any custom events. Let us say, we want to raise CalendarVisibilityChanged event every time the visibility of the calendar changes. The visibility of the calendar is toggled by clicking on the image button.
The following are the steps to raise CalendarVisibilityChanged event from the CalendarUserControl
Step 1: Create CalendarVisibilityChangedEventArgs class that will contain the event data.
public class CalendarVisibilityChangedEventArgs : EventArgs
{ private bool _isCalendarVisible; // Constructor to initialize event data public CalendarVisibilityChangedEventArgs(bool isCalendarVisible) { this._isCalendarVisible = isCalendarVisible; } // Returns true if the calendar is visible otherwise false public bool IsCalendarVisible { get { return this._isCalendarVisible; } }
}
Step 2: Create CalendarVisibilityChangedEventHandler delegate. "sender" is the reference variable that points to the instance of the CalendarUserControl, that raises this event. "CalendarVisibilityChangedEventArgs" object will contain "CalendarVisibilityChanged" event data.
public delegate void CalendarVisibilityChangedEventHandler(object sender, CalendarVisibilityChangedEventArgs e);
Step 3: Create CalendarVisibilityChanged event. Remember that, an event is a variable of type delegate. In the line below, we are just creating a variable "CalendarVisibilityChanged" of type "CalendarVisibilityChangedEventHandler" with delegate keyword infornt of it.
public event CalendarVisibilityChangedEventHandler CalendarVisibilityChanged;
Step 4: Create a protected virtual method to raise the event. Since this method is protected and virtual, all classes deriving from the CalendarUserControl class can overridde this method, if they wish to do so. This method enables the derived classes to do some additional work before the event can be raised. Just before raising the event, we are checking if CalendarVisibilityChanged is null. If you are not sure about this, please don't worry. This will be much clear in the next video session, when we discuss about consuming CalendarVisibilityChanged event.
protected virtual void OnCalendarVisibilityChanged(CalendarVisibilityChangedEventArgs e)
{ if (CalendarVisibilityChanged != null) { CalendarVisibilityChanged(this, e); }
}
For example, if we have a class "DerivedCalendarUserControl" that derives from CalendarUserControl class. "DerivedCalendarUserControl" can override the virtual "OnCalendarVisibilityChanged()" method as shown below. "CalendarVisibilityChanged" will only be raised when "base.OnCalendarVisibilityChanged(e);" is invoked. So, using a "protected virtual" method to raise events is a very useful technique.
public class DerivedCalendarUserControl : CalendarUserControl
{ // Other DerivedCalendarUserControl class methods, properties etc.. protected override void OnCalendarVisibilityChanged(CalendarVisibilityChangedEventArgs e) { // Do some additional work befor raising the event base.OnCalendarVisibilityChanged(e); }
}
For the HTML and code samples used in the demo please visit my blog at the following link
http://csharp-video-tutorials.blogspo...
asp.net core docker Raising custom events from user controls Part 106 | |
243 Likes | 243 Dislikes |
81,628 views views | 524K followers |
Education | Upload TimePublished on 3 Jan 2013 |
Related keywords
wcf vs web api,ado.net core,sql server management studio,webkinz,webadvisor,creating destiny,creating apple id,craigslist nj,wcf one piece,asp.net core 3,ajax players,weber grill parts,webtoon,tutorials by hugo,csharp corner,mvc design pattern,asp.net machine account,servers for minecraft,asp.net core dependency injection,ado.net tutorial,creating google account,services angular,ajax ontario,asp.net mvc tutorial,user control dependency property,asp.net cos'è,csharp assembly,user control vs custom control,tutorialspoint python,sql join,events calendar,services briefcase,asp.net core web api,ajax jquery,wccftech,craigslist ny,creating an outline,asp.net zero,csharp foreach,server memes,events of respiration,sql date format,services online,chase,serverless architecture,server resume,wcf c#,server books,tutorialspoint javascript,mvcc connect,ado.net mysql,services technologies gps,ajax deadpool,user control interface,server jobs,cvs,website,mvc tutorial,costco hours,wcf service application,tutorialspoint spring,serverless,wcf soap,creating logo,creating a business plan,user control c#,wcf cat,wcf test client,cool math games,user control in asp.net example,services & training hse colombia sas,servicestack,citibank,asp.net core identity,sql union,ajax parking,sql database,asp.net core logging,mvconnect,asp.net guida,cunyfirst,wcf nba,csharp download,wcfi foundation,csharp online,wcf authentication,tutorials near me,http://asp.net,server 2019,ado.net descargar,web of dreams,chernobyl,serverminer,ajax cleaner,ado.net visual studio 2019,webassign,ado.net vs entity framework,ado.net visual studio 2017,csharp list,sql like,asp.net mvc,asp.net core tutorial,sqlite,wcfm,creating a website,ajax roster,mvc architecture,http://ado.net,events in july,asp.net core mvc,ajax soccer,server hosting,events in dhaka for students,user control settings,user control events,wcfi,ajax dish soap,capital one,server rack,creating a society full of kindness,tutorialspoint html,csharp interface,craigslist,user control panel windows 10,webroot,tutorialspoint reactjs,ajax request,wcf dragon ball,user control vs custom control wpf,asp.net core 2.2,tutorialspoint python 3,sql developer,webster,services transmission company sas,user control considerations,sql group by,asp.net core signalr,services manager,mvc framework,ajax paving,mvc near me,creating facebook account,user control vs form,tutorialspoint spring boot,mvc map,csharp online compiler,events today,asp.net download,sql between,ado.net c# pdf,wcf 2019 nba,services tag dell,csharp switch,ado.net ventajas y desventajas,csharpstar,user control load event,wcf tutorial,creating resume,tutorialspoint,ajax meaning,csharp-video-tutorials.blogspot,tutorials dojo,csharp string format,central park 5,ado.net c#,asp.net core github,server status,ajax fc,server jobs nyc,asp.net core swagger,sql formatter,creating an effective presentation,credit karma,services group,server error in '/' application,services windows,asp.net core 3.0,sql injection,wcf ria services,tutorialspoint c#,calculator,ado.net entity data model,sql insert,tutorialspoint tableau,creating email account,services google play apk,creating gmail account,sqlyog,creating love lyrics,asp.net core 3 release date,sql server,creating meaning,server job description,tutorials by a,servicenow,webcam,mvc hours,webmd symptom,user control windows 10,csharp array,creating infographics,events management,user control and freedom,csharp enum,ajax call,asp.net core 2. guida completa per lo sviluppatore,asp.net core,server pro,server status ffxiv,webcrims,cheap flights,asp.net core hosting,events in dhaka,services sas,tutorialspoint java,tutorialspoint java compiler,webmd,csharp to json,college football,ado.net dataset,csharp dictionary,events synonym,user control wpf,cnn,creating synonym,user controlpasswords2,website builder,tutorialspoint sql,asp.net web api,server side rendering,weber grills,creating youtube channel,sql server 2017,creating info,mvc nj,events near me today,tutorialspoint spark,ado.net oracle,asp.net core download,csharp to vb.net,webster bank,webstaurant,tutorialsystems,ajax post,services fms publish announcement,services.msc no abre,user control panel,ajax jersey,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,csharp random,century 21,services consultores,services consulting,mvcsd,mvcsc,services.msc,ado.net pdf,asp.net core configuration,ajax marvel,sql update,asp.net tutorial,mvc medical,events that increased trade volume,ado.net entity data model visual studio 2019,wcfs international curriculum,events today dhaka,mvc2,ado.net entity data model visual studio 2017,events in august,chase online,events near me,wcf api,costco,server jobs near me,events in bd,webex,events in javascript,sql meaning,user control in mvc,sql tutorial,sql commands,ado.net entity framework,ajax tavern,user control xaml,tutorialsteacher,ajax javascript,user control 2,services desk,events meaning in bengali,events nearby,ajax greek,events in dhaka 2019,csharp tutorial,mvc pattern,ado.net sql server,ado.net connection,asp.net identity,mvcu,creating a personal goal,asp.net core middleware,events in bangladesh,wcf web service,mvc webadvisor,web store,mvcc,webmail,mvci,mvctc,events of homeostasis,
Không có nhận xét nào:
Đăng nhận xét