MESCIUS SPREAD for ASP.NET 10.0J
AllowServerValidators プロパティ (TextCellType)

サーバー側でカスタムバリデーターコントロールを使用してセルのデータを検証できるかどうかを取得または設定します。
構文
'Declaration
 
Public Property AllowServerValidators As Boolean
public bool AllowServerValidators {get; set;}
次のサンプルコードは、AllowServerValidatorsプロパティを設定します。
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
   <commandbar backcolor="Control" buttonfacecolor="Control" buttonhighlightcolor="ControlLightLight" buttonshadowcolor="ControlDark"></commandbar>
   <sheets>
      <FarPoint:SheetView SheetName="Sheet1"></FarPoint:SheetView>
   </sheets>
</FarPoint:FpSpread>
      
<asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="Error of server side" OnServerValidate="CustomValidator2_ServerValidate"></asp:CustomValidator>

protected void Page_Load(object sender, EventArgs e)
{
  if (IsPostBack) return;
  TextCellType txt = new FarPoint.Web.Spread.TextCellType();
  txt.AllowServerValidators = true;
  txt.Validators.Add(CustomValidator2);
  FpSpread1.ActiveSheetView.Cells[1, 1].CellType = txt;
  FpSpread1.ActiveSheetView.Cells[1, 1].BackColor = Color.LightPink;
}
protected void CustomValidator2_ServerValidate(object source, ServerValidateEventArgs args)
{
int value = 0;
args.IsValid = int.TryParse(args.Value, out value) && value < 10;// Accept integer number less than 10;
}
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Height="200" Width="400">
   <commandbar backcolor="Control" buttonfacecolor="Control" buttonhighlightcolor="ControlLightLight" buttonshadowcolor="ControlDark"></commandbar>
   <sheets>
      <FarPoint:SheetView SheetName="Sheet1"></FarPoint:SheetView>
   </sheets>
</FarPoint:FpSpread>
      
<asp:CustomValidator ID="CustomValidator2" runat="server" ErrorMessage="Error of server side" OnServerValidate="CustomValidator2_ServerValidate"></asp:CustomValidator>

Protected Sub Page_Load(sender As Object, e As System.EventArgs)
        If IsPostBack Then
         Return
                
Dim txt As New FarPoint.Web.Spread.TextCellType()
  txt.AllowServerValidators = True 'New property to enable server validating with validator controls
  txt.Validators.Add(CustomValidator2)
  FpSpread1.ActiveSheetView.Cells(1, 1).CellType = txt
  FpSpread1.ActiveSheetView.Cells(1, 1).BackColor = Color.LightPink
End Sub
Protected Sub CustomValidator2_ServerValidate(source As Object, args As ServerValidateEventArgs)
 Dim value As Integer = 0
 args.IsValid = Integer.TryParse(args.Value, value) AndAlso value < 10  'Accept integer number less than 10
End Sub
参照

TextCellType クラス
TextCellType メンバ

 

 


© MESCIUS inc. All rights reserved.