zoukankan      html  css  js  c++  java
  • RegisterStartupScript和RegisterClientScriptBlock的区别

         1、  //注册到 <form> 尾部 ,HTML元素已加载完毕
           this.Page.ClientScript.RegisterStartupScript(this.GetType(), "age1", "Test('" + tbAge.ClientID + "');", true);

        2、 //注册到<form> 头部 ,此时HTML还未加载!
               //js会报 缺少对象
               this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "age2", "Test('" + tbAge.ClientID + "');", true);

          3、
       protected void BtnTest_Click(object sender, EventArgs e) { //注册到 <form> 尾部 ,HTML元素已加载完毕 //this.Page.ClientScript.RegisterStartupScript(this.GetType(), "age1", "Test('" + tbAge.ClientID + "');", true); //UpdatePanel 是用ajax后用上面的没有效果 ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "age1", "Test('" + tbAge.ClientID + "');", true); } protected void BtnTest2_Click(object sender, EventArgs e) { //注册到<form> 头部 ,此时HTML还未加载! //js会报 缺少对象 //this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "age2", "Test('" + tbAge.ClientID + "');", true); //使用ajax的UpdatePanel 后 //页面上的this.UpdatePanel1控件ID ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, typeof(Page), "key1", "Test('" + tbAge.ClientID + "');", true); }
  • 相关阅读:
    怎么在一个线程结束后回到主线程?
    iOS KVC & KVO
    iOS添加到购物车的简单动画效果
    如何在键盘出现时滚动表格,以适应输入框的显示
    iOS开发之多媒体播放
    算法的时间复杂度(一)
    SPI通信
    三级管的原理
    stm32之595(spi芯片)
    stm32之Systick(系统时钟)
  • 原文地址:https://www.cnblogs.com/qiuyueguangxuan/p/4183960.html
Copyright © 2011-2022 走看看