zoukankan      html  css  js  c++  java
  • 在Master母版页中通过FindControl()方法获取服务器控件

    在Master母版页中路程经过过程FindControl()要领获取办事器控件 1、办事器控件与代码都位于母版页

      Response.Write("<script language=javascript>window.alert('" + TextBox1.Text + "')</script>");

      TextBox tb1 = (TextBox)FindControl("TextBox1");

      Response.Write("<script language=javascript>window.alert('FindControl()获取:" + tb1.Text + "')</script>");

      /*以下用处纰缪:

      *TextBox tb2 = (TextBox)Master.FindControl("TextBox1");

      *Response.Write("<script language=javascript>window.alert('" + tb2.Text + "')</script>");

      */

      2、办事器控件与代码都位于内部实质意义页

      Response.Write("<script language=javascript>window.alert('" + TextBox1.Text + "')</script>");

      ContentPlaceHolder cpl1 = (ContentPlaceHolder)Master.FindControl("ContentPla ceHolder1");

      TextBox tb1 = (TextBox)cpl1.FindControl("TextBox1");

      Response.Write("<script language=javascript>window.alert('Master.FindContro l()获取:" + tb1.Text + "')</script>");

      //或:

      ContentPlaceHolder cpl2 = (ContentPlaceHolder)FindControl("ContentPlaceHolde r1");

      //在此FindControl()代表Master.FindControl(),在Master母版页中查寻控件

      TextBox tb2= (TextBox)cpl1.FindControl("TextBox1");

      Response.Write("<script language=javascript>window.alert('FindControl()获取:" + tb2.Text + "')</script>");

      /*以下用处纰缪:

      *TextBox tb1 = (TextBox)FindControl("TextBox1");

      //在此FindControl()代表Master.FindControl(),在Master母版页中查寻控件,而TextBox1在Content内部实质意义页中,以是找不到TextBox1控件

      *Response.Write("<script language=javascript>window.alert('" + tb1.Text + "')</script>");

      */

      3、办事器控件位于母版页,代码位于内部实质意义页

      TextBox tb1 = (TextBox)Master.FindControl("TextBox1");

      Response.Write("<script language=javascript>window.alert('" + tb1.Text + "')</script>");

      4、办事器控件位于内部实质意义页,代码位于母版页

      TextBox tb = (TextBox)ContentPlaceHolder1.FindControl("TextBox1 ");

      Response.Write("<script language=javascript>window.alert('" + tb.Text + "')</script>");

      /*纰缪的用处:

      * Response.Write("<script language=javascript>window.alert('" + TextBox1.Text + "')</script>");
  • 相关阅读:
    PNG文件格式具体解释
    opencv2对读书笔记——使用均值漂移算法查找物体
    Jackson的Json转换
    Java实现 蓝桥杯VIP 算法训练 装箱问题
    Java实现 蓝桥杯VIP 算法训练 装箱问题
    Java实现 蓝桥杯VIP 算法训练 单词接龙
    Java实现 蓝桥杯VIP 算法训练 单词接龙
    Java实现 蓝桥杯VIP 算法训练 方格取数
    Java实现 蓝桥杯VIP 算法训练 方格取数
    Java实现 蓝桥杯VIP 算法训练 单词接龙
  • 原文地址:https://www.cnblogs.com/leotan/p/1832319.html
Copyright © 2011-2022 走看看