.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Pankaj Mishra
alex morco
Imran Ghani
Post New Web Links

Raising an event in .Net 3.5

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

I know in .Net 1.1, I used the following code when raising an event.

if (SetTaskDescription != null)
                    SetTaskDescription(this, new TaskDescriptionEventArgs("Current Row : FILTERING Row. Total Rows : " +
 this.MasterGridViewTemplate.Rows.Count)); }

But in .Net 3.5, do I have to check if SetTaskDescription != null ? I mean, I will ignore the if and just use the following code:

SetTaskDescription(this, new TaskDescriptionEventArgs("Current Row : FILTERING Row. Total Rows : " +

View Complete Post

More Related Resource Links

Accessing master page from content page? Raising Event?

Here is my situation:I have a user control that has a menu in it.  This user control sits on my master page.  It is my main navigation menu for my application.I am having an issue where, on one of my pages, users seem to be leaving the page before committing all changes to the database, which results in a loss of data.So what I want to accomplish is - if the user is leaving this page and the data has not been saved yet, I want to prompt the user and say something like "The information is not yet saved, are you sure you want to leave this page" in a modal popup.So my approach is this:In my menu user control, create an event handler called MenuClicked that is raised when the menu web control's (in the user control) MenuItemClicked is raised, I raise my custom MenuClicked event.Then on my master page, I can catch this event in NavMenu_MenuClicked.My problem is - I need to catch this event in my content page, not the master?Am I approaching this correctly?Thanks in advancesb

Avoid raising an event


Hello everyone.

Here's my question, I have an event that's being raised on datagrid once the collection has changed, I use that to store position of columns in config file, like this:


void dgvRezultati_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
      int i = 0;
      string configFile = xmlPostavke.ConfigFile;
      XmlDocument doc = new XmlDocument();

        foreach (SortableGridViewColumn column in dgvRezultati.Columns)
          column.ColumnIndex = i;
          xmlPostavke.SpremiRasporedStupaca(column.ColumnName, column.ColumnIndex, doc);
      catch (Exception) 


But  now I have a method that removes columns, like this:

private voi

Raising an Event in another thread from a Thread



I have a Polling thread which runs an infinite loop . and I have another thread(business) which is invoked by the UI thread based on user actions.

I need to raise an event in the polling thread from the business thread so that at the begining of the business thread (which is created  by

the UI thread bcause of a user action - say Button click - ) the event is raised and the event needs to be raised inside the Polling thread which is executing some complex logic inside a loop  and need to stop all of its operation temperorly so that the business thread can continue its work and after it completes the polling thread can resume its work , I have done the synchronization using the lock state ment but since the logic inside the loop of the polling thread is complex and takes time to complete each iteration , I need to stop the polling threads exection at the exact moment the business thread starts its execution - two threads share some  common hardware devices .


Is there any way to do this in .Net




WPF Datagrid, raising "RowEditEnded" event


I know that WPF datagrid has "RowEditEnding" event , but I need to fire the event on after the Row has comitted to check if the newly added row is duplicated and merge the duplicated row. My datagrid has "CanUserAddRow" property set to True.

I am using EntityObservableCollection that extends ObservableCollection to synchronize my entity with the collection. So, i considered OnCollectionChanged event, but the "InsertItem" event is raise once user click on the new item place holder row, which means the object is still empty and I cant check for duplicate. I also considered CollectionView CurrentItemChanged event, but it does not provide the behavior I wished.



//my Model class

public class InventoryIngredient : EntityObject, IDataInfoError{

# region properties

public Guid InventoryIngredientID;
public Guid IngredientID;
public Guid UnitID;
public string

INotifyPropertyChanged isn't raising event


Hi, I'm trying not to create new thread about this topic. When I googled this, I found many links over this topic. I'm so desperate trying to find a solution, so I make a question here. I made a simple CAL / Prism project implementing INotifyPropertyChanged. Here is the link to my project TestProject.zip


<UserControl x:Class="PrismTestProject.Modules.Test.Views.TestView"
	d:DesignHeight="300" d:DesignWidth="300">
		<TextBlock Text="{Binding Path=MyText}" FontSize="20" HorizontalAlignment="Center" TextAlignment="Center" />


View Model

TargetException while raising COM event for interop


Hi experts,

I've one DLL loaded in two Internet Explorer Windows. While loading the first one, a singleton is created. This singleton raises COM events, which are received by JavaScript in the Internet Explorer windows. This works fine and both IE windows are getting the events. The whole scenario works on my development machine. After deploying everything to a production machine, I get a TargetException (the object does not match the target type) when raising the COM event, but only when a function in the singleton is called from the second IE window. When I call a function from singleton instance from the first IE window everything works fine and I receive the events. I am completely lost because it works on my dev machine.

My event is defined in an interface, however the delegate is created within the singleton class.

The event definition:

[ComVisible(true )]
public interface IOcsExposedEvents
void CallStatusEvent(string message);

Microsoft ESP Event raising


Hi I want to raise an event for "STROBES_TOGGLE" inorder to switch on lights.

I can do this by using the below methods



In the second method i want to give inputs as "shift+k" ,etc which is used to take input from keyboard.


BUt input for me will be getting from external hardware which is not joystick or keyboard

Ex: a boolean variable which indicates the state of light (on/off)...I have to relate this boolean variable instead of keyboard input


In this case how can i raise that event inorder to switch on that strobe light.



Radio Button Event

Here I have explained the events of radio button with javascript.
Let me explain the scenarion first,
We are having two radio button say radioobtn1 and radiobtn2. If I click on the button 1 then I need to show one DIVor FORM. same as when I click on radiobtn 2. I have given the code for the above scenarion.

how to impose javascript event processing?


If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?


Dropdown Event (Template Field)



I have grid view control that includes a dropdown control in a template field.

I wish to execute some code when the value is changed in the dropdown list.  Can't figure out how to capture this event though?

Any suggestions?

Event ID 1011 - DefaultAppPool World Wid Web Pub. Serv. fatal communication error

We have a Windows 2003 server running IIS6 1.1 Framework. We have also installed a DNS and Active Directory in the same machine.

We're randomly getting the error you can see below. Sometimes it causes the recycling of process w3wp.exe (which on my understanding represents the application pool worker processd) and other times results on this process hanging and not responding to any request. To do iisrest temporarly solves the problem.

We were pointed to a possible permissions problem between the user we were runnig the DefaultAppPool with and registry entries used by the iis. We noticed the default predifined user we used, Network Service, wasn't found in the Active Directory, so we changed it by the default configurable user, IWAM_MACHINE_NAME, which is under the IIS_WPG Active Directory Grupo, which, in theory has the correct permissions to run the application pool.

Well, none of this worked and we are still getting this error.

This is driving us crazy and think the problem might have to do with having the Domain Controller/Active Directory and the IIS6 running on the same machine. We'll try now uninstalling this DC pointing to another one to see what happens.

Any help would be appreciated.

Thanks in advance,


Event Type: Warning

Event not raised while parsing xml file



In Visual Studio 2010 ASP.NET 4.0

I want to write a procedure to validate a xml file with a xsd. I found some examples on the web but the one i chose does not work as attended. The example uses XmlReader with a XmlReaderSettings and a ValidationEventHandler.

Here is the code

Protected Sub VerifyDes(ByVal filename As String)

        Dim xslDes As XmlReaderSettings = New XmlReaderSettings()
        xslDes.Schemas.Add("", "http://www.mysite.com/xsd/ValidData.xml")
        xslDes.ValidationType = ValidationType.Schema
        xslDes.ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings

        AddHandler xslDes.ValidationEventHandler, AddressOf xslDesValidationEventHandler

        Dim des As XmlReader = XmlReader.Create(filename, xslDes)

        While (des.Read())

        End While

    End Sub

    Protected Sub xslDesValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)

        'some code here
    End Sub

I tested this procedure with a xml file which was well formed but contained some elements which were not conform to the xsd.

No event or error occured. It said the file was valid.

Then i tested with a badly formed file. A XmlException was raised but nothing happened with the ValidationEventHandler.

It seems lik

How to set up microsoft application blocks 4.0 to talk to event viewer


I need to set up the microsoft application blocks 4.0 on the server and connect it to my web project.  I need to set it up so that all the errors are logged in the event viewer.  So far I have found out how to set up a flat file listener and send the error to a log file but, not to the event viewer.  Any suggestions would be helpful.

    Composite control: How to bubble a textbox's TextChanged event?


    I've created a composite control that contains several controls, including a textbox. I'm trying to expose the TextChanged event of the textbox as an event on the composite control. I understand that events can be bubbled up the control hierarchy and handled at a higher level, which I've attempted to do, but I can't get the bubbled event to fire. When I drop the control on an aspx I can see the TextChanged event, I can subscribe to the event, but nothing ever happens. Any suggestions? Here is what I think is the relevant code:

    // My event
    private static readonly object EventTextChanged = new object();

    //Handle the bubbled event
    EventHandler textChangedHandler = (EventHandler)Events[EventTextChanged];
    protected override bool OnBubbleEvent(object source, EventArgs e) 
        bool handled = false;

    Reporting services in 2008 r2 how to get a report in a print button click event in my c#.net page


    how to  get a report in my c#.net page button lick event also steps to call a report from asp.net to reporting services


    Thanks in advance

    Creating Event Handler in Code behind


    Hi, so I have a control that is created in the code behind and generates fine but I can't figure out how to create an event handler for it.  I've found plenty of examples for it in C sharp, but none of them seem to apply to VB.  What I want to do is essentially this:

    myDropDownList.SelectedIndexChanged = "Event to do here"

    but it doesn't seem to work for me.

    Any suggestions are appreciated.

    Subscribing to .Net event from COM



    Can somebody tell me how to subscribe to .net event from the COM through interoperability?

    namespace EventSource
        public interface IBugEvents
            void Hungry();
            void Found(string item);
        public class Bug
            public delegate void HungryEventHandler();
            public delegate void FoundEventHandler(string item);
            public event HungryEventHandler Hungry;
            public event FoundEventHandler Found;

    Can somebody tell me how to Subscribe to the Hungry and Found events from the COM?If possible help me with COM Code.

    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend