Monday, July 26, 2010

How to find java scripts enable in a postback - Asp.net, Javascripts

<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script runat="server">
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            string js = this.Request.Form[this.htnEnableJavaScripts.UniqueID];
            if (!string.IsNullOrEmpty(js) && js.Equals("yes"))
            {
                this.cusValidator.IsValid = true;
                this.cusValidator.Enabled = false;
                
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.ClientScript.RegisterStartupScript(this.GetType(), 
                this.GetType().Name, 
                string.Format("document.getElementById('{0}').value = 'yes';", 
                this.htnEnableJavaScripts.ClientID), true);
        }        
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button runat="server" ID="btnPostback" Text="Postback" />
        </div>
        <asp:HiddenField runat="server" ID="htnEnableJavaScripts" Value="no" />
    </form>
</body>
</html>

No comments:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...