你要先查看一下生成的html代码中, 你自定义控件生成后的标签ID是什么

解决方案 »

  1.   

    只要它是从System.Web.UI.Control或其基类继承的,用它的ClientID属性就可以获得它在客户端的ID。
      

  2.   

    生成的HTML如下:
    <cc3:APDateTimePicker id="APDateTimePicker1" runat="server" Height="21px" Width="136px"DateTimePickerURL="/Common/FrmDateTimePicker.aspx">
    </cc3:APDateTimePicker>
    APDateTimePicker是从WebControl继承过来的
      

  3.   

    老大这不是生成的HTML,上面几位大侠的意思是你在IE中看到的“源代码”里面你的控件被解释成什么了!!!
      

  4.   

    id一般没问题,看看在后台cs代码文件中的声明部分,看APDateTimePicker1是不是被声明成private的了,若是,改成public试试。
      

  5.   

    各位大侠自定义控件生成的HTML如下:ID为何在IE中变了,我如何获得这个ID?
    <TABLE><TR><TD><input name="APDateTimePicker2:_ctl0" type="text" value="2003-09-03 10:38:22" onchange="__doPostBack('APDateTimePicker2$_ctl0','')" language="javascript" id="APDateTimePicker2__ctl0" style="height:22px;width:136px;" /></TD><TD><input type="image" name="APDateTimePicker2:_ctl1" title="选择日期" src="http://localhost/BSCRM/BSCRM/images/DateTime.Ico" align="Middle" border="0" style="height:22px;width:24px;" /></TD></TR></TABLE></TD>
      

  6.   

    document.all("APDateTimePicker2__ctl0").valuedocument.getElementById("APDateTimePicker2__ctl0")
      

  7.   

    document.all("APDateTimePicker2__ctl0").valuedocument.getElementById("APDateTimePicker2__ctl0")
      

  8.   

    我是想写成通用的组件,不能直接应用名称来赋值,而需要程序获得IE中组件的ID
      

  9.   

    在服务端取得ClientID, 把这个值在aspx页面输出
      

  10.   

    To panyee:
    我跟踪了组件ClientID还是APDateTimePicker2,不是在IE源文件中看到的APDateTimePicker2__ctl0!