Click here to Skip to main content
15,922,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a page with 3 views in a multiview control and a single save button for all these views.
But i'm saving the page viewwise only.

please help me in validating the controls for that specific views only in the aspx page.

my code is here
XML
<script type = "text/javascript">
       function validate(V) {
           if (V.toString() == "1") {
               var valid = Page_ClientValidate("vw0");
           }
           if (V.toString() == "1") {
               var valid = Page_ClientValidate("vw1");
           }
           if (V.toString() == "1") {
               var valid = Page_ClientValidate("vw2");
           }
           if (!valid) {
               document.getElementById('<%= lblvalid.ClientID %>').innerHTML = " * Indicates Invalid Data";
               return false;
           }
           else {

               return true;
           }
       }
   </script>


i know only to pass single argument to the function


<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" OnClientClick="return validate('1')" />&nbsp;&nbsp;


my controls in different views have validategroup
vw0
vw1
vw2 respectively

please help me
Posted

try this:
JavaScript
<script type="text/javascript">
       function validate(V) {
           var valid;
           if (V.toString() == "1") {
               valid = Page_ClientValidate("vw0");
           }
           if (V.toString() == "1") {
               valid = Page_ClientValidate("vw1");
           }
           if (V.toString() == "1") {
               valid = Page_ClientValidate("vw2");
           }
           if (!valid) {
               document.getElementById('<%= lblvalid.ClientID %>').innerHTML = " * Indicates Invalid Data";
               return false;
           }
           else {
 
               return true;
           }
       }
   </script>
 
Share this answer
 
Comments
Member 10112611 13-Aug-13 7:17am    
i don't want all to be validsated at a time..if i'm on vw1 , only that controls to be validated...
i solved ti by passing the mutliview index to the java script...

JavaScript
function validate() {

    var MultiView = document.getElementById('<%= mvwAuditorPage.ActiveViewIndex %>');
    var valid = Page_ClientValidate(MultiView);
    
    if (!valid) {
        document.getElementById('<%= lblvalid.ClientID %>').innerHTML = " * Indicates Invalid Data";
        return false;
    }
    else {    
    return true;
    }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900