RequiredFieldValidator disappears when user clicks on upload button (On Postback)

Posted by Divs99 under ASP.NET on 11/28/2012 | Points: 10 | Views : 1279 | Status : [Member] | Replies : 0

here iam facing problem with required field validator disappears for the textbox controls when user browse the file and clicks upload button using file upload control.

ee 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);

<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"/>


(No response found.)

Login to post response