How can I stop a postback from occuring after a

Results 1 to 2 of 2

Thread: How can I stop a postback from occuring after a

  1. #1
    Join Date
    Dec 1969

    Default How can I stop a postback from occuring after a

    I have a page where after I click an webcontrol asp:button , i enter a client side javascript function that I call Validate()where I perform some complex data validation. <BR><BR>i.e &#060;asp:button id="Button1" runat="server" Text="Submit" &#060;/asp:button&#062;<BR><BR>In the Page_Load Event of the page i wrote the following statement so the button would go to that function after it was clicked: <BR><BR>Button1.Attributes.Add("onclick", "return Validate()") <BR><BR><BR>My problem is that I do not know how to stop the page from going to the server after my function is completed. For example, if I find an error in my validation function, I would like to display an error message with an alert statement and then stop all processing and not go to the server. <BR><BR>I have not been able to figure out how to cancel the postback after the button is clicked. If anyone knows how to stop the postback , can you send me some examples of the code in VB<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: How can I stop a postback from occuring aft

    You might want to look into the CustomValidator class, or write your own validator by inheriting from BaseValidator.<BR><BR>You will be able to provide a server-based implementation as well as an optional client-side function (which you have already written). With a client-side validation function in place, I think the behavior will automatically be what you want.<BR><BR>Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts