Search code examples
javascriptjqueryequivalent

if not postback javascript equivalent


In we have IsPostBack that we use to validate if is or isn't a postback.

if (!IsPostBack)
{
    // Validate initially to force asterisks
    // to appear before the first roundtrip.
    Validate();
}

There is a javascript/jQuery equivalent?

Note that

I don't wanna a solution using any other language than javascript (not excluding html, since it is not a programming language). Those questions below show how to do it using , I don't wanna that!. I want a solution in javascript (or jQuery) ONLY.


Solution

  • No, there is no direct equivalent. You'd have to track the state of the application using JavaScript. One popular way of doing that is hashbang urls. Ex:

    http://domain.com/#some-state or http://domain.com/#/some-state

    window.location.hash exposes the hashbang url and there are frameworks like AngularJS that make working with hashbang urls to control state and what view is displayed very easy.