Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Richard C Bishop 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 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 28-Nov-12 14:40pm    
Make asp button property CausesValidation="true"
Pro Idiot 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900