1

i am using validators for validation and on linkbutton i am diaplaying popup. my problem is i want to disable linkbutton means until page is validated means the popup should not be displayed till the page gets validated

<asp:LinkButton ID="LinkButton1" runat="server"  CssClass="addProduct-disable" Enabled ="false"
       Text="Assign Filter Criteria"  CausesValidation="true"></asp:LinkButton>
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
neha dhage
  • 21
  • 1
  • So, what you are saying is that you want to run validation on a form when the user clicks the linkbutton, and if the page is valid you want to display a client-side popup message? A link button that is disabled can not run validation. – Jeremy Aug 11 '10 at 12:53

2 Answers2

0

Try to validate client-side, if possible, via AJAX-Methods.

AGuyCalledGerald
  • 7,882
  • 17
  • 73
  • 120
0

You may consider using the jQuery event.preventDefault() method.

 $('[id$="LinkButton1"]').click(function(event) {  
     if(! valdiateYourPage() ) {
         event.preventDefault();     
         // display validation errors or something
      }
      else {
           //proceed as normal
      }
  });

Put your page validation logic in the valdiateYourPage() javascript method. If it valdiates, then process as normal, if not then preventDefault() will stop any further event execution by your LinkButton.

cecilphillip
  • 11,446
  • 4
  • 36
  • 40
  • rather than event.preventDefault(), you can just call return false; See this discussion: http://stackoverflow.com/questions/1357118/javascript-event-preventdefault-vs-return-false – Daniel Dyson Aug 11 '10 at 13:13