zoukankan      html  css  js  c++  java
  • 服务器端调用客户端方法

    多好用的两个方法呀:
    RegisterStartupScript(key, script)
    RegisterClientScriptBlock(key, script)


      这两个方法都接受两个字符串作为输入。第二个参数 script 是要插入到页面中的客户端脚本,包括 <script> 的起始标记和终止标记。第一个参数 key 是插入的客户端脚本的唯一标识符。

      这两个方法唯一的不同之处在于从“何处”发送脚本块。RegisterClientScriptBlock() 在 Web 窗体的开始处(紧接着 <form runat="server"> 标识之后)发送脚本块,而 RegisterStartupScript() 在 Web 窗体的结尾处(在 </form> 标识之前)发送脚本块。

    例子:
    protected void cBox_Condition_SelectedIndexChanged(object sender, EventArgs e)
        {
            string strDataType = cBox_Condition.SelectedValue.ToString().Split('&')[1].ToString();
            if (strDataType == "DATETIME")
                this.Page.RegisterStartupScript("key", "<script>ShowDateTimeBtn();</script>");
            else
                this.Page.RegisterStartupScript("key", "<script>HideDateTimeBtn();</script>");
        }

         function ShowDateTimeBtn()
         {
            prefix = document.getElementById('imgDateTime').style;
            prefix.visibility = "visible";
         }
         function HideDateTimeBtn()
         {
            prefix = document.getElementById('imgDateTime').style;
            prefix.visibility = "hidden";       
         }
  • 相关阅读:
    桟错误分析方法
    gstreamer调试命令
    sqlite的事务和锁,很透彻的讲解 【转】
    严重: Exception starting filter struts2 java.lang.NullPointerException (转载)
    eclipse 快捷键
    POJ 1099 Square Ice
    HDU 1013 Digital Roots
    HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
    HDU 1159 Common Subsequence
    HDU 1069 Monkey and Banana(动态规划)
  • 原文地址:https://www.cnblogs.com/spymaster/p/661729.html
Copyright © 2011-2022 走看看