TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chevy Mark Sunderland
NA
188
167.3k
Disable the RequiredFieldValidator where condition
Aug 5 2012 10:33 AM
Hello there.
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";
I tried this code but in the all condition I have RequiredFieldValidator enables.
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.
<asp:TextBox ID="StartDateFag" runat="server" Width="70">
</asp:TextBox>
<asp:TextBox ID="StartEndFag" runat="server" Width="70">
</asp:TextBox>
<asp:RequiredFieldValidator ID="StartEndFag1" runat="server" Enabled="true" ControlToValidate="StartEndFag"
ErrorMessage=Error 1"></asp:RequiredFieldValidator>
<asp:TextBox ID="StartDateHoe" runat="server" Width="70">
</asp:TextBox>
<asp:TextBox ID="StartEndHoe" runat="server" Width="70">
</asp:TextBox>
<asp:RequiredFieldValidator ID="StartEndHoe1" runat="server" Enabled="true" ControlToValidate="StartEndHoe"
ErrorMessage=Error 2"></asp:RequiredFieldValidator>
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;
}
}
Reply
Answers (
2
)
Remove brower History in ASP.NET?
sorting in gridview