Recently, I wrote the event receiver and found that if the Chinese field is obtained directly using properties. afterproperties ["applicant"], the value is null and cannot be obtained. Then I suddenly found that the value can be obtained using an English field. Do Chinese fields need to be encoded? This is true after tests.
The Code is as follows:
Public override void itemadding (spitemeventproperties properties) {base. itemadding (properties); // obtain the site spweb = properties. openweb (); // If the Web is not empty if (web! = NULL) {// get the list splist list = web. Lists [properties. listid]; // if the list is not empty if (list! = NULL) {// obtain the field string fieldname = List. fields. getfield (workleaveconfig. workleave_title ). internalname; // string worktitle = properties. afterproperties [fieldname] = NULL? String. empty: properties. afterproperties [fieldname]. tostring (); // obtain the value if (worktitle. indexof ("test")> = 0) {properties. errormessage = "unable to ask for leave! "; Properties. Cancel = true: