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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Cant stop MouseDoubleClick Event from bubbling in treeview

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :WPF

I have assigned an event handler for  mousedoubleclick on treeviewitems in a style. However, after the eventhandler has finished executing for the treeviewitem that i double clicked, it runs again for all its parent nodes right to the top of the tree. I have specified e.Handled = true at the end of the event handler but it doesnt seem to have any effect.

I have included the full code below. The treeview is made up of different object types, and therefore i have a different HierarchicalDataTemplate for each of these types (maybe thats the problem).

Anyway, i would like to know of a way to stop the event from bubbling up so the MouseDoubleClick event is only handled for the treeviewitem i double clicked

Sorry for the amount of code i had to provide to demonstrate the problem, but this has been nagging me for days!


Classes i am using:

using System; 

View Complete Post

More Related Resource Links

Event bubbling

The article Event bubbling was added by xiii on Wednesday, June 02, 2010.

Server controls like Datagrid, DataList, Repeater can have other child controls insidethem. Example DataGrid can have combo box inside datagrid. These child control do notraise there events by themselves, rather they pass the event to the container parent

Treeview node to add onclick event to download files

 Hi, I would like to know how to add onclick evend to a TreeNode so that the file can be downloaded.   How can I implement below sample code to a TreeNode? <a href="#" onclick="popup('/directory1/Somefile.doc'); return false;" target="download"> Somefile </a> <script language="javascript"> function popup(url) { popWin = window.parent.open(url, 'popWindow', 'height=900, width=900, toolbar=no, menubar=yes, scrollbars=yes, titlebar=no, resizable=yes,location=0, directories=no, status=no'); } </script> I have TreeNodePopulate event to populate nodes like this: protected void DocRepository_TreeNodePopulate(object sender, TreeNodeEventArgs e) { .... String[] files = Directory.GetFiles(fullPath); foreach(String file in files) { TreeNode newNode  = new TreeNode(Path.GetFileName(file), Path.GetFileName(file)); node.ChildNodes.Add(newNode); } }   Thank you in advance.              

How to stop Datagrid SelectionChange from SelectionChanged Event



I have a DataGrid which is binded with a List. Consider I have 10 Items in the List, so in the combobox also.

Currently 2nd Item is selected in the DataGrid.

Now I am selecting the 3rd item in the DataGrid.

In the DataGrid SelectionChanged event, I am doing some validation and validation fails so I don want my Selection is changed from 2nd item to 3rd item or the selection should remain in 2nd item.

Please let me know how to do this?

In the DataGrid SelectionChanged event, I tried to set DataGrid.SelectedItem = 2ndItem.

But this didn't work properly.

Hope, my requirement is clear. If you have any doubt then please feel free to ask me.



disable a single intem in dropdownlist or stop the ddl change event for a single item


hello guys,

I am trying something apart of my boundries, is there any way to disable a single intem in dropdownlist or stop the ddl change event for a single item.

any feadback would be appriciable.

Thanks and Regards

Inderjeet Singh Khalsa

How to handle treeview selected node changed event



From my below sample code, I don't want to use Sessions to handle each click event inside treeview selected node changed.

Secondly, if you suggest me to use treenode.SelectedValue then I would say my values are dyanmically generated.

Everytime a node a clicked, the selected node value is sent in the next request xml to get response and xml schema is different for each click. How do I handle this each click event other than using session variables. I thought of using Request.Item (and integrating with URL redirect property) but I don't want to use that.


Dim trNode As New TreeNode
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then        
            trNode.Text = "Not Postback"
            Session("Flag") = 1
        End If
    End Sub

Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TreeView1.SelectedNodeChanged
        If Session.Item("Flag") = 1 Then
            trNode.Text = "Is PostBack"
            Session("Flag") = 2
        End If

stop event propagation


I have two click handlers hooked on the click of an anchor. I want the first handler to be able to cancel the propagation of the event to the 2nd handler.   Also, I want to be able to cancel the default click behavior of the anchor.

Problem is, StopPropagation is not found as a method on the "e" object passed to the event handler. Why is StopPropagation not found?


     <a id="googleLink" href="http://www.google.com">google</a>

<script type="text/javascript">
  $(document).ready(function ()

    var click1Func =
          function (e)
            alert('in click1 click handler. ' + e.type);
            return false;

    var click2Func =
          function ()
            alert('in click2 click handler');




TreeView, how to set an event handler when using hierarchichalDataTemplate

I've defined a databound treeview like this: 
<TreeView Margin="10" Name="tvProtocolos" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto" Height="430" MinWidth="230">
            <HierarchicalDataTemplate ItemsSource="{Binding Path=Children}">
                 <TextBlock Text="{Binding Path=Name}" ></TextBlock>        
But I can't find a way to define the Event handler function for the Select property, so that this function is run every time one selects an element in the tree.

Event Handler (send mail task) firing multiple times for each dataflow error - How can I stop the da


I've set up an OnError event handler for my package which sends an email containing the name of the file that fails import through my dataflow task. The problem is the dataflow experiences three errors (one for each task it is attempting to complete) which in turn causes three duplicate emails to be sent.

I'd prefer to stop the dataflow task completely rather than allow it to try to complete the remaining tasks after the first error. Is this possible? Alternately, how can I set up my event handler to only send one email regardless of the number of dataflow errors that occur?

Thanks in advance!

Event bubbling - Mousehover event for child controls



I have a form and some controls inside it.

I want to fire an event when user enter the form and when he leaves the form .

this.MouseEnter += (sender, e) =>
   //do stuff

this.MouseLeave += (sender, e) =>
   //do stuff

the problem with that is when I move mouse over the child control, form's mouseleave event is triggered.

I don't want this to happen (even if the mouse over control is still over the form).


How to solve that?

I don't want to set any events on the children (because there are many controls and some of them create dynamically).

I also don't want to use any timers to check the position....

I know I can use IMessageFilter, and add to application:

 Application.AddMessageFilter(new MyMessageFilter());
 public bool PreFilterMessage(ref Message m)
if (m.Msg == 0x2a1) { }
But this will fire for entire application and not just for one form, and I don;t know how to detect inside PreFilterMessage the current control.



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?

JQuery Treeview plugin is not working with Ajax page load in ie8


Hi there,

I developed a page where i m using jquery treeview plugin to generate tree. It worked fine on FF, IE8 with out ajax.

But when my page loads thro' ajax call in IE8, it is not collapsing or expanding tree.

Any idea?

Thanks in advance.

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;
    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