sharepoint - Detect a change in a rich text field's value in SPItemEventReceiver? -


i have event receiver attached custom list. current requirement implement column level security rich text field (multiple lines of text enhanced rich text).

according post, can field's before , after values so:

object obefore = properties.listitem[f.internalname]; object oafter = properties.afterproperties[f.internalname]; 

the problem i'm running issues comparing these 2 values, lead false positives (code detecting change when there wasn't one).

exhibit a: using tostring on both objects

obefore.tostring()

<div class=externalclass271e860c95ff42c6902be21043f01572> <p class=msonormal style="margin:0in 0in 0pt">text.  </div> 

oafter.tostring()

<div class=externalclass271e860c95ff42c6902be21043f01572> <p class=msonormal style="margin: 0in 0in 0pt">text.  </div> 

problems?

  • html tags capitalized
  • random spaces (see additional space after margin:)

using getfieldvalueforedit or getfieldvalueashtml seem result in same values.

"ok," say, lets compare plain text values.

exhibit b: using getfieldvalueastext

fortunately, method strips of html tags out of value , plain text displayed. however, using method led me discover additional issues whitespace characters:

in before value:

  1. sometimes there additional newline characters.
  2. sometimes spaces displayed non-breaking spaces (ascii char code 160)

question:

how can detect if user changed rich text field in event receiver?

  1. [ideal] detect change html or text or white space
  2. [acceptable] detect changes text or white space
  3. [not good] detect changes text characters (strip non-alphanumeric characters)

what happens if set listitem field new value , read out? give same formatting?

object obefore = properties.listitem[f.internalname]; properties.listitem[f.internalname] = properties.afterproperties[f.internalname] object oafter = properties.listitem[f.internalname]; //dont update properties.listitem[f.internalname] = obefore; 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -