Click here to Skip to main content
12,701,601 members (34,293 online)
Rate this:
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 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);

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2017
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