Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi,
 
here iam facing problem with required field validator disappears for the textbox controls when user browse the file and clicks upload button using asp.net file upload control.
Posted 28-Nov-12 5:14am
Comments
richcb at 28-Nov-12 11:22am
   
You need to post your code or noone will be able to help you. This is not a question nor does it provide enough information to warrant a helpful response.
deepisingh at 28-Nov-12 12:14pm
   
see my below code
 


function setValidations() {
var selValue = document.getElementById("DDLID").value;
var reqVal = document.getElementById("RequiredFieldValidatorID");
var reqVal2 = document.getElementById("RequiredFieldValidatorID2");
if (selValue == "a") {
ValidatorEnable(reqVal, false);
ValidatorEnable(reqVal2, false);
}
else {
ValidatorEnable(reqVal, true);
ValidatorEnable(reqVal2, true);
}
}
</script>
 

 

<asp:DropDownList ID="DDLID" runat="server" onchange="setValidations()" ValidationGroup="abc">
<asp:ListItem Value="a">No
<asp:ListItem Value="b">Yes

<asp:TextBox ID="TextBox1" runat="server" >
<asp:RequiredFieldValidator ID="RequiredFieldValidatorID" runat="server"
ControlToValidate="TextBox1" ErrorMessage="*" ValidationGroup="abc" >
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button2" runat="server" Text="upoad" OnClick="btnUpload_Click" />
<asp:RequiredFieldValidator ID="RequiredFieldValidatorID2" runat="server" ValidationGroup="abc"
ControlToValidate="FileUpload1" ErrorMessage="*" >
<asp:Button ID="Button1" runat="server" Text="save" OnClick="btnUpload_Click"/>
Maksud Saifullah Pulak at 28-Nov-12 14:40pm
   
Make asp button property CausesValidation="true"
Pro Idiot at 28-Nov-12 23:03pm
   
And Add validation group [ValidationGroup="abc"] to the button

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 605
1 Sergey Alexandrovich Kryukov 305
2 BillWoodruff 259
3 PIEBALDconsult 220
4 CPallini 220


Advertise | Privacy | Mobile
Web04 | 2.8.141029.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100