2009-05-28 17 views
1

私はsharepointの機能としてカスタムリストを作成しました。カスタムリストの共有ポイントの検証

いくつかのフィールドでいくつかの検証を実行する必要があります。私はここからそれを取るん

public override void ItemAdding(SPItemEventProperties properties) 

: IVEは

SPItemEventReceiver

から継承し、メソッドを実装する必要がCLSSを作成しましたか?リストアイテムなどにアクセスするにはどうすればいいですか...

ありがとう

答えて

2

これには多くのサンプルがあります。 たとえば、this one

それは、このコードスニペットを使用して電子メールの列を検証します。ここでは

public override void ItemAdding(SPItemEventProperties properties) 
{ 
    base.ItemAdding(properties); 

    // only perform if we have an Email column 
    if (properties.AfterProperties["Email"] != null) 
    { 
     // test to see if the email is valid 
     if (!IsValidEmailAddress(properties.AfterProperties["Email"].ToString())) 
     { 
      // email validation failed, so display an error 
      properties.Status = SPEventReceiverStatus.CancelWithError; 
      properties.Cancel = true; 
      properties.ErrorMessage = "Please enter a valid email address"; 

     } 
    } 


} 
1

は良いオプションです:SharePointで

正規表現フィールド検証.. www.codeplex.com/SharePointRegEx

これは、正規表現を追加してユーザが入力した値を検証できるカスタムフィールドです。また、「エラーメッセージ」フィールドもあります。