First of all I must say that I am a newbie when it comes to net (C#).
Here is my problem.
I need enable or disable the RequiredFieldValidator in my aspx page where condition.
- If the TextBox ID="StartDateFag" and TextBox ID="StartEndFag" are empty or full I need disable the RequiredFieldValidator with ID="StartDateHoe1";
- If the TextBox ID="StartDateHoe" and TextBox ID="StartEndHoe" are empty or full I need disable the RequiredFieldValidator with ID="StartEndFag1";
Can you help me?
If you have link for similar task, please give it me.
Can you explain any one or any sample code related this.
Your help would be very appreciated.
Thanks in advance for your time and hints.
Cheers.
if (s == "button1")
{
if (!string.IsNullOrEmpty(StartDateFag.Text) && !string.IsNullOrEmpty(StartEndFag.Text))
{
StartDateHoe1.Enabled = false;
}
else if (string.IsNullOrEmpty(StartDateFag.Text) == true && string.IsNullOrEmpty(StartDateFag.Text) == true)
{
StartDateHoe1.Enabled = false;
}
}
if (s == "button2")
{
if (!string.IsNullOrEmpty(StartDateHoe.Text) && !string.IsNullOrEmpty(StartEndHoe.Text))
{
StartEndFag1.Enabled = true;
}
else if (string.IsNullOrEmpty(StartDateHoe.Text) == true && string.IsNullOrEmpty(StartEndHoe.Text) == true)
{
StartEndFag1.Enabled = false;
}
}
Jignesh TrivediPosted Aug 5, 2012, 11:50 PM
you may use custom validation instead of RequiredFieldValidator.
In custom validation you may check your condition and depending on condition you may validate data.....
please refer
http://msdn.microsoft.com/en-us/library/9eee01cx%28v=vs.71%29.aspx
http://www.codeproject.com/Articles/8635/Custom-Validation-Summary-in-ASP-NET
hope this will help you.
Chevy Mark SunderlandPosted Aug 6, 2012, 6:23 AM