I am using a hidden field 'Isjsenabled' to detect whether Client's Javascript is enabled or disabled. If Javascript is enabled, Javascript function will be fired and it will set hidden field's value to 1.
I want to check the hidden value from server side Page_load. But the problem is Javascript gets fired after Page load.
Do you have any suggestion ?
Html Part
<script type="text/javascript">
$(function() {
$("#<%= Isjsenabled.ClientID %>").val(1);
});
</script>
<input id="Isjsenabled" runat="server" value ="0" type="hidden" />
Code Behind Part
protected void Page_Load(object sender, EventArgs e) {
HtmlInputHidden hdn = this.FindControl("Isjsenabled") as HtmlInputHidden;
if (hdn != null)
if (hdn.Value != null && hdn.Value == "0")
Helper.SetCookie("IJE", "0");
else
Helper.SetCookie("IJE", "1");
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…