使用JavaScript来确定一个ASP.NET页面是回发 [英] Use javascript to determine if an ASP.NET page is a postback

查看:104
本文介绍了使用JavaScript来确定一个ASP.NET页面是回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能确定一个ASP.NET页面是从JavaScript回发?
所以基本上一个JavaScript相当于C#Page.IsPostBack的。

Is it possible to determine if an ASP.NET page is a postback from javascript? So basically a javascript equivalent of C# Page.IsPostBack.

感谢。

推荐答案

我只想把一个标签呈现在JavaScript

I would just put a render tag in the javascript

var isPostBack = <%= Page.IsPostBack ? "true" : "false" %>;

把真与假作为字符串应该怎样做才能消除任何可能出现的问题的类型转换为字符串在C#true.ToString()通常是真,这是在JavaScript错误。

Putting the "true" and "false" as strings should be done to eliminate any possible issues converting the type to a string as in C# true.ToString() is usually "True" which is an error in javascript.

这篇关于使用JavaScript来确定一个ASP.NET页面是回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆