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

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

EventHandler triggers another EventHandler

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :SharePoint
I have two EventHandlers - A and B. EventHandler A populates items in Child list, when Parent list creates a new item. Or vise versa, deletes items in Child list when Parent list deletes an item. There is a ParentID in Child list to refer back to ID column in Parent list. EventHandler B duplicates items from Site 1 to Site 2. i.e. creates a new item in Child list of Site 2, when Site 1 creates a new item in Child list. Or vise versa, deletes item in Child list in Site 2 when Site 1 deletes an item in Child list. The two Child lists are almost identical except Site 2 Child list has SourceID pointing back to ID column in Site 1 Child list ID field.   Site 1                                      Site 2 Parent    | EventHandler A    V Child   --- EventHandler B --->  Child   Now if I create/delete item in Parent list of Site 1, Child list of Site 2 will be affected, thanks to EventHandler A and B. Here A triggers B. If I create/delete item in Child list of Site 1, Child list of Site 2 will be affected as well, here only EventHandler B is triggered. My question is: Is there anyway to tell in EventHandler B, that it is triggered originally from Parent lis

View Complete Post

More Related Resource Links

Search for Gridview on Eventhandler

Hello, I was woundering if there is a way to seach for a gridview on event handler.? I have three gridviews in which i can insert from and on my insertbutton codebehind, I want to check the gridview i am using so i could get the datakeynames for insert into the database. Does anyone have ideas. Thaks  

ItemAdding Eventhandler

Hi, i developed an ItemAdding Event handler. i want this eventhandler to be generic. i am trying to use this in the code, when debugged i get Object reference not set to an instance. can anyone help me in the right direction?             string siteUrl = properties.WebUrl;    //throws object reference not set to an instance here                          SPSecurity.RunWithElevatedPrivileges(delegate()             {                 using (SPSite CurrentSite = new SPSite(siteUrl))                 {                     using (SPWeb CurrentWeb = CurrentSite.OpenWeb())                     {                         SPList CurrentList = CurrentWeb.Lists[properties.ListId];      &

document library eventhandler (itemupdating & itemcheckedin) & winword infopanel issues

Hi all   I have eventhandlers  (itemupdating & itemcheckedin) which will fill few metadatafields (A,B) depending how one other (C)is set manually. All is going just fine in cases: - change C in datasheet view, - upload one & fill C - create new & fill C from document info panel & check in - open existin & change C from document infopanel & check in All updates to sharepoint goes just fine. After changing C and checking in, when I re-open the document in winword, the infopanel shows correct value in C, but old values in A and B (even thou sharepoint views show ok values in A and B after check in from winword)   Any best practises how the connection between infopanel and sharepoint should be dealt. I am suspectin that infopanel uses some cached values, and not refreshing data after eventhandler change metadata.   -heikki  

Redirecting to another page from an eventhandler on ItemAdding event

Hi,   I want to redirect to another page from an eventhandler on ItemAdding event. So please help me achieve in achieving this.    Thanks in Advance

EventHandler not working for survey item

Hi All,I'm quite new to sharepoint. Have tried a lot of search but couldn't get anything to work.I'm trying to make an eventhandling method to work in my sharepoint site. The code for the eventhandler is took from online itself:     RedirectSurvey   public class RedirectSurvey : SPItemEventReceiver {     public override void ItemAdding(SPItemEventProperties properties)     base.ItemAdding(properties);   SPList SahilSurvey = properties.OpenWeb().GetList("http://isvpoc3:14246/Lists/Sahil");   string currentResponse =   "Is Sahil a good boy?"].ToString();   if (currentResponse != "Yes")  {properties.ErrorMessage = "The only valid response is YES you nitwit!!";   true;     } }}} I build it and put the dll in GAC. Put the feature.xml and elements.xml in the feature folder.Activated the feature in the site.Elements.xml:     xml version="1.0" encoding="utf-8" ?>     Elements xmlns="http://schemas.microsoft.com/sharepoint/">     Receivers ListTemplateId="102">     Receiver>     Name>RedirectSurvey</Name>     Type>ItemAdding</Type>     SequenceNumber>20000</SequenceNumber>     Asse

EventHandler Firing only for administrator users



I have wrote an event handler which is working very good.

Today I finally tested it using a non administrator user and the event handler is just not firing (it ignore the code).


My code start like this:

public override void ItemAdding(SPItemEventProperties properties)

            StreamWriter sw = File.CreateText("c:\\splog.txt");
            sw.WriteLine("Code Ran");
            SPSite spSite = new SPSite("http://sharepoint");
            SPWeb web = spSite.OpenWeb("/");



When I use an administrator account I can see the file created and got no problem, when I use a non administrator account the code is just not running.

Thank you very much for any help.

GridView -> ItemTemplate EventHandler setzen


Hi all,


i have a dynamically created GridView with a CheckBox by means of TemplateField.ItemTemplate. Now i want to add an EventHandler (CheckedChanged) on it. Is this possible?

          TemplateField tempField = new TemplateField();
          itemplateCheckBox chb = new itemplateCheckBox(dc_.ColumnName, GridView2);
          tempField.ItemTemplate = chb;
          tempField.HeaderText = dc_.ColumnName;


    public void InstantiateIn(Control container)
      CheckBox cb = new CheckBox();
      cb.DataBinding += new EventHandler(this.bindBooleans);
      cb.CheckedChanged += new EventHandler(this.checkBoxChanged);



TreeView EventHandler


Hi all. I have a problem with adding an EventHandler to the TreeView control. TreeView is added to form dynamically.

When I click on a tree node nothing happens.

Help me to solve this problem. 

Here part of class that generates treeview:


 public class Menu_constructour
 public void generate_tree(PlaceHolder field)
 TreeView tree = new TreeView();
            tree.ID = "tree";

WebForm1 web = new WebForm1(); tree.SelectedNodeChanged += new EventHandler(web.tree_SelectedNodeChanged); tree.PopulateNodesFromClient = true; TreeNode node1 = new TreeNode(); node1.Text = "Parent node1"; TreeNode _node11 = new TreeNode(); _node11.Text = "Child node"; TreeNode _node12 = new TreeNode(); _node12.Text = "Child node2"; TreeNode node2 = new TreeNode(); node2.Text = "Parent node2"; node1.ChildNodes.Add(_node11); node1.ChildNodes.Add(_node12); tree.Nodes.Add(node1); tree.Nodes.Add(node2); // ????????? ?????? ?? ???????? field.Controls.Add(tree); } }


Sandbox EventHandler Issue


Developed Sandbox Event Handler in VS2010, 

debugged on http://sharepoint:10000/sites/varun, its working fine.

I have generated .wsp file by following below link:


When I have attached solution to Central admin, http://sharepoint:10000/sites/varun & tried to

work on another site collection too & activated it but event is not working.

can anyone resolve it? where I am wrong?

Please give me details how to deploy on another site collections &  on production server too


Data Points: Disabling Constraints and Triggers


What to do when you need to disable triggers and constraints to perform data synchronization and other tasks with an offline database.

John Papa

MSDN Magazine April 2007

Can I use TCP sockets within managed funcs, triggers and stored procedures?

I have seen nothing prohibiting this, but have not yet had time to write some test code. Does anyone know for sure if SQL Server 2008 prohibits or allows TCP sockets for communications, inside a C# SQL/CLR function or method? I guess it must because this is implict when creating data connections and so on, which are obvioulsy allowed. Thanks Cap'n  

I have 3 triggers defined on an sqlserver2008 table and I can't find them with c#

I've got the code below and when I run it, it always says there are 0 triggers in table.Triggers.  I added some debugging code checkin the table.HasDeleteTrigger, etc. and from that, I get the exception: "To accomplish this action, set property HasDeleteTrigger." when I try to set it to bool hasDeleteTrigger. I can get stored procedures find, just not triggers. Below is my problem code: foreach (Database database in databaseCollection) { if (database.Name.Equals(catalogName)) { // first we need to delete triggers associated with all tables that begin // with our prefix. we can skip our the framework tables because those // don't have triggers on them // grab all tables, filter for non prefixed ones in foreach loop so we can delete triggers from non prefixed ones results.AddRange(from Table table in database.Tables select table.Name); foreach (var tableName in results) { var table = new Table(database, tableName, CrSyncDbSchemaName); table.Refresh(); bool hasDeleteTrigger = table.HasDeleteTrigger; bool hasAfterTrigger = table.HasAfterTrigger; bool hasInsertTrigger = table.HasInsertTrigger;



Triggers when Log-Shipping is used

When we restore a db using Log-shipping, do the triggers in the destination db get fired from the changes occured in the shipped log? I guess the answer is negative but just want to make sure I am not missing anything. Thanks in Advance.  

How can I use triggers ?

I have a Database with some tables in an Asp.Net project (C#),I wanna to run a method in C# whenever some data was written in the tables. I know I have to use triggers, but I don't know how!!!It would be appreciated if you guide me. P.S:I'm using SQLExpress 2008,
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