The name 'ClientScript' does not exist in the current context

后端 未结 3 1445
攒了一身酷
攒了一身酷 2020-12-31 01:39

I have a behindcode javascript. it is to show a javascript dialog box.

however, it keep show this error

The name \'ClientScript\' does not exist in         


        
相关标签:
3条回答
  • 2020-12-31 01:43

    For cs file the sample is;

    ClientScript.RegisterClientScriptBlock(this.GetType(), "{some text for type}", "alert('{Text come to here}'); ", true);
    

    for masterpage cs the sample is;

    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "{some text for type}", "alert('{Text come to here}'); ", true);
    
    0 讨论(0)
  • 2020-12-31 01:49

    Try:

    Page.ClientScript
    

    instead to see if it makes a difference.

    0 讨论(0)
  • 2020-12-31 01:57

    On the master page try ScriptManager.RegisterStartupScript() instead. Watch out, the signature slightly differs from Page.ClientScript.RegisterClientScriptBlock().

    • Documentation of the ScriptManager Class
    0 讨论(0)
提交回复
热议问题