الأربعاء، 7 ديسمبر 2011

Simple Trick to check if Javascript supported in Client Browser using ASPX


protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["JSChecked"] == null)    //JSChecked -indicates if it tried to run the JavaScript version
        {
            Session["JSChecked"] = "Checked";
            string path = Request.Url + "?JScript=1";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "redirect", "window.location.href='" + path + "';", true);
        }
        if (Request.QueryString["JScript"] == null)
            Response.Write("JavaScript is not enabled.");
        else
            Response.Write("JavaScript is enabled.");
    }

0 التعليقات: