Itemadding implements data verification-the problem that the value of properties. afterproperties is null in the Chinese field

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.