如何在前端检测回发(aspx)

cho*_*obo 2 c# asp.net jquery webforms

我需要检测前端中的回发,以便我可以使用它与JQuery来更改页面加载的类.我怎样才能做到这一点?

Mun*_*Mun 7

您可以检查IsPostBack属性.例如:

<script type="text/javascript">
    $(function()
    {
        var isPostBack = <%=Page.IsPostBack.ToString().ToLower()%>;

        if (isPostBack)
        {
             alert("Postback");
        }
    });
</script>
Run Code Online (Sandbox Code Playgroud)