第一个问题你可以参考文档中的 Using Validation Controls 章节,里面有详细的步骤使用前端验证,你可以直接把下面的代码复制使用。
- if (IsPostBack) return;
- FpSpread1.Sheets[0].RowCount = 10;
- FpSpread1.Sheets[0].ColumnCount = 7;
- // RequiredFieldValidator, from code
- FarPoint.Web.Spread.TextCellType txt1 = new FarPoint.Web.Spread.TextCellType();
- RequiredFieldValidator rfv = new RequiredFieldValidator();
- rfv.ErrorMessage = "RequiredFieldValidator, from code: value required!";
- txt1.Validators.Add(rfv);
- FpSpread1.ActiveSheetView.Cells[0, 0].Text = "RequiredFieldValidator, from code";
- FpSpread1.ActiveSheetView.Cells[0, 1].CellType = txt1;
- // CompareValidator, from code
- FarPoint.Web.Spread.TextCellType txt4 = new FarPoint.Web.Spread.TextCellType();
- CompareValidator cv = new CompareValidator();
- cv.ErrorMessage = "CompareValidator, from toolbox: password does not match! Enter "Spread"";
- cv.ValueToCompare = "Spread";
- txt4.Validators.Add(cv);
- FpSpread1.ActiveSheetView.Cells[3, 0].Text = "CompareValidator, from code";
- FpSpread1.ActiveSheetView.Cells[3, 1].CellType = txt4;
复制代码
|