Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
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.
Posted 28-Nov-12 6:14am
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);


<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 Peter Leow 315
1 Mika Wendelius 275
2 CHill60 190
3 TheRealSteveJudge 184
4 Abhinav S 170
0 Sergey Alexandrovich Kryukov 8,613
1 OriginalGriff 6,546
2 Peter Leow 3,897
3 Zoltán Zörgő 3,456
4 Richard MacCutchan 2,472

Advertise | Privacy | Mobile
Web04 | 2.8.150123.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2015
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