Wrong object when trying to get DocumentEventArgs

Kyle Pham asked on August 21, 2020 11:28

I am trying to implement a function that triggers when the user clicks on saving a Page by using a global event. The DocumentEventArgs should return the current page which the user is clicking, but it returns the wrong page You can check on my code as bellow.

link text

Recent Answers


Dmitry Bastron answered on August 21, 2020 12:20

Hi Kyle,

Document_Update_After event is firing for every page, so if you amend any page of any type it will fire. Then you have if condition to filter out only pages of specific type. Are you saying that inside if block in e.Node you are seeing a different page from what you have just saved?

0 votesVote for this answer Mark as a Correct answer

Kyle Pham answered on August 21, 2020 17:02 (last edited on August 21, 2020 17:03)

Dear Dmitry Bastron, Yes that what I talking about.I alreay have a if condition to filter page with type class as the screenshot which I provided.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on August 21, 2020 19:04

Dear Kyle, this is really strange and should not happen. Could you provide more information about your setup?

  • What is the configuration of your page type?
  • Do you have code generated for this type in your solution? Without including this .gen.cs file you will always see only TreeNode type in the debug
  • Do you have any other global event handlers in your solution? If yes, do you change objects inside these event handlers?
  • Try on before update event, is it working for you?
  • Also, what Kentico version is it? Is it Portal Engine or MVC?
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.