开发者

validations and Fileupload contorls in updatepanel

开发者 https://www.devze.com 2023-03-08 15:24 出处:网络
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

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 workarou开发者_如何学编程nds.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消