C # postback page

Is it possible to stop page postback for any click event based on some check

+3
source share
3 answers

You can use client-side validation of different types. With ASP.NET WebForms, the easiest way is likely to be a built-in validator (for example: RequiredFieldValidator).

+1
source

if you mean doing this on the client side (i.e. making sure that the page doesn’t come back), you will probably have to do this in Javascript.

just attach the JS event function of the JS event to what you want to test, and let it return false;when you don't want it to return server-side ASP.NET.

0

. .

Page.ClientScript.RegisterOnSubmitStatement(string key, string script)

onsubmit, :

function __doPostBack(eventTarget, eventArgument) {
     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
     }
}
0

Source: https://habr.com/ru/post/1763020/


All Articles