Tao

          Tao obeys its own inherent Nature

          Add javascript to the client

           

          Show how to add script to the client in aspx file.

          /// <param name="rbl">RadioButtonList to apply script to</param>
          /// <param name="page">The Page the script is going to be appended to</param>
          /// <param name="script">The script to append</param>
          public static void SetRadioButtonListItemScript(RadioButtonList rbl, Page page, string script)
          {
          for (int idx = 0; idx < rbl.Items.Count; idx++)
          {
          RegisterClientObjectFunction(page, rbl, idx, script);
          }
          }

          /// <param name="page">The Page the script is going to be appended to</param> /// <param name="rbl">RadioButtonList to apply script to</param> /// <param name="idx">the index of the radio button</param> /// <param name="script">The script to append</param> static private void RegisterClientObjectFunction(Page page, RadioButtonList rbl, int idx, string script)
          {
          StringBuilder sw = new StringBuilder();
          if (!page.IsStartupScriptRegistered(rbl.ClientID + "_" + idx.ToString() + "script"))
          {
          sw.Append(@"<SCRIPT>");
          sw.Append(@"document.getElementById('" + rbl.ClientID + "_" + idx.ToString() + "').onclick=function() {" + script + "return true;}");
          sw.Append(@"</SCRIPT>");
          page.RegisterStartupScript(rbl.ClientID + "_" + idx.ToString() + "script", sw.ToString());
          }
          }

          static private void RegisterClientObjectFunction(Page page, CheckBox chk, string script)
          {
          StringBuilder sw = new StringBuilder();
          if (!page.IsStartupScriptRegistered(chk + "script"))
          {
          sw.Append(@"<SCRIPT>");
          sw.Append(@"document.getElementById('"+chk.ClientID + "').onclick=function() {" + script + "return true;}");
          sw.Append(@"</SCRIPT>");
          page.RegisterStartupScript(chk.ClientID + "script", sw.ToString());
          }
          }

           

          posted on 2007-08-30 18:34 wade 閱讀(216) 評(píng)論(0)  編輯  收藏 所屬分類: Dot.netJavascript


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          <2007年8月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          統(tǒng)計(jì)

          常用鏈接

          留言簿(7)

          隨筆分類

          隨筆檔案

          相冊(cè)

          Photo

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 沙湾县| 石家庄市| 五华县| 铁岭县| 伊金霍洛旗| 贺州市| 驻马店市| 香河县| 门头沟区| 凤台县| 巧家县| 隆化县| 鄢陵县| 苍梧县| 腾冲县| 凭祥市| 公安县| 建瓯市| 新邵县| 闽侯县| 泰来县| 阿拉善右旗| 庆阳市| 上思县| 常德市| 望奎县| 二连浩特市| 东丰县| 盐源县| 南华县| 镇赉县| 普定县| 开化县| 甘洛县| 怀仁县| 张家港市| 镇康县| 威宁| 西青区| 郓城县| 大悟县|