Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

c# event : publish and subscribe

Posted on 2014-02-14
4
Medium Priority
?
64 Views
Last Modified: 2016-06-16
I am trying to setup event in the server side, so when request coming, i register an event, and from other places i can subscribe to this event, say certain properties change, i want to raise or execute the event. Is it something possible in asp.net (c#)?  So similar to what JS has, publish an event, and subscribe from diff places.
0
Comment
Question by:johndenny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 2000 total points
ID: 39860137
Yes you can.

Essentially you can create a class that inherits from a standard control.  

public class MyUserControl : UserControl
{
   //this allows you to "publish" the event
    public delegate void onMyEvent(int AParam);
    public event onMyEvent MyEvent;
 
    public MyUserControl()
    {
          //subscribe to the event
          MyEvent += MyEventHandler;
    }

   // this occurs when the event happens
    public void MyEventHandler(int Param)
    {
                // do something
    }

}
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 41655414
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question