Haw to use ClientScript.IsClientScriptBlockRegistered

ClientScript.IsClientScriptBlockRegistered is used to determine whether the client script block is registered already or not.

In almost all places where I find ClientScript.IsClientScriptBlockRegistered in Google, it is used with one parameter (string KEY )

But if you debug you will determine that ClientScript.IsClientScriptBlockRegistered("key") always return FALSE!

The proper using is:

if (!ClientScript.IsClientScriptBlockRegistered("Script1"))

          Page.RegisterClientScriptBlock("Script1", "<script type=\"text/javascript\">alert()</script>");

Or...

if (!ClientScript.IsClientScriptBlockRegistered(this.GetType(), "Script1"))

          ClientScript.RegisterClientScriptBlock(this.GetType(), "Script1", "alert()", true);


5 Comments

  • Thx! I just missed the typeof part in my code ;)

  • Satisfying posting. It would appear that quite a large amount of that the stages are depending upon
    that the originality aspect. “It’s a funny thing about life whenever you refuse to accept anything then again that
    the best, you very often discover it.” by W. Somerset Maugham.
    .

  • Hi this is somewhat of off topic on the other hand I was wondering if online resources use WYSIWYG
    editors or if you need to manually code with HTML. I’m starting a blog soon conversely have no coding
    knowledge so I wanted to search for guidance from someone with experience.
    Any other help would be greatly appreciated!

  • I adore your wordpress web template, wherever would you download it out of?

  • There have been incredibly a lot of details this option to take into consideration.
    This is usually a fantastic examine talk about.
    I provde that the thoughts above because universal inspiration in spite of this clearly
    you will get a hold of questions such as one
    you raise up the place that the most essential factor will be working in honest very first-class faith.
    I don?t be acquainted with if guidelines have emerged
    about things such because that, on the other hand Just about certainly that your job is obviously recognized as a
    inexpensive game. Both young ones feel the impact of an moment’s pleasure, for the remainder of their lives.

Comments have been disabled for this content.