ramin149
دوشنبه 12 مهر 1389, 16:31 عصر
سلام من چک کردن کنترل هام رو داخل کلاس انجام دادم ولی هنگام معرفی خطا می ده نمونه کدم
public void txt_name(TextBox name, Image img_error, Label lbl_error, Boolean cname)
{
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ControlToValidate = name;
rfv.ErrorMessage = "نام خالی است";
if (rfv.IsValid)
{
cname = true;
img_error.ImageUrl = ad.ImgTrue;
}
else
{
lbl_error.Text += "<br>" + rfv.ErrorMessage;
img_error.ImageUrl = ad.ImgFalse;
cname = false;
}
}
خطا در خطی که قرمز شده
و نوع خطا
cannot implicitly convert type 'system.web.ui.webcontrols.textbox' to 'string'
public void txt_name(TextBox name, Image img_error, Label lbl_error, Boolean cname)
{
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ControlToValidate = name;
rfv.ErrorMessage = "نام خالی است";
if (rfv.IsValid)
{
cname = true;
img_error.ImageUrl = ad.ImgTrue;
}
else
{
lbl_error.Text += "<br>" + rfv.ErrorMessage;
img_error.ImageUrl = ad.ImgFalse;
cname = false;
}
}
خطا در خطی که قرمز شده
و نوع خطا
cannot implicitly convert type 'system.web.ui.webcontrols.textbox' to 'string'