开发者

How to call a method in 3 tier architecture

I have a class file cls_PurchaseValidae.cs in which i have written a code like below:

publ开发者_C百科ic void txtMfgDate_Validating(TextBox txtMfgDate,ErrorProvider errorProvider1,string datetoValidate)
{
  //method for validating the text box.
  ValidateMfgDate(txtMfgDate, errorProvider1,datetoValidate);
}

and i m calling this event in the code behind frm_Purchase.cs like this:

private void txtMfgDate_Validating(object sender, CancelEventArgs e)
 {
   objPurchaseValid.txtMfgDate_Validating(txtMfgDate,errorProvider1,datetoValidate);
 }

but i m getting the error:

Error 1 The name 'datetoValidate' does not exist in the current context

How can i resolve it. Thanks in advance


I am not sure why do you want to pass around both TextBox txtMfgDate, and string datetoValidate? Shouldn’t datetoValidate be always txtMfgDate.Text? Anyway, you can do:

private void txtMfgDate_Validating(object sender, CancelEventArgs e)
{
   objPurchaseValid.txtMfgDate_Validating(txtMfgDate,errorProvider1,txtMfgDate.Text);
}

if that is what you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜