Hi i have a problem in using fileupload in updatepanel wherein i have 3 mandatory text fields impemented using required field validator and a file uplaod control. yes file upload control does not work async so i have implemented a trigger on it
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
//3 Text Boxes with required Field validators in btnAddvalidation group
<asp:LinkButton ID="AddButton" runat="server"
OnClick="AddButton_Click" ValidationGroup="btnAdd" Text="Add node></asp:LinkButton>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="AddButton" />
</Triggers>
Okay so thats all good. Now this is where the tricky part comes.Currently whenever i click on AddButton, the valdation is firing but soon followed by a very unfirendly postback, I want this trigger to happen only if the 3 validators pass validation, if any one of them fails, then to stay on the screen. So, any workarounds.
Okay I Have Found a solution for it:
And in checkVAl()
function checkVal() { var txt1 = document.getElementById('<%= txt.ClientID %>');
if(txt1.value == "")
{
ValidatorEnable(document.getElementById('<%= reqfieldvalidator.ClientID %>'), true);
return false;
}
else {
return true;
}
}
Have to love Javascript for the simple solutions it gives. Hope this helps someone
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.