我在web页面引入了一个控件但是出现了那个提示。
<tr><td>
    <asp:Image ID="Image1"style="CURSOR: hand;" onclick="popUpCalendar(this, form1.txt_year, 'yyyy')" runat="server" ImageUrl="~/icon_calendar.gif" />
    </td></tr>
在网上查了下说需要id,但是我哪里已经有id了。请高手赐教 谢谢

解决方案 »

  1.   

    你试着把onclick="popUpCalendar(this, form1.txt_year, 'yyyy')"去掉。
    看行不行如果可以,就在CS文件使用:
    Image1.Attributes.Add("onclick", "popUpCalendar(this, form1.txt_year, 'yyyy')");
    ASPX文件中就不要留这段话了
      

  2.   

    ID="Image1"style="CURSOR: hand;" 中间没空格???
      

  3.   

    现在编译是没有错误了。但是我一点那个按钮image的时候会出现error page这个错误,就是javascript错误,我想实现的功能想一点那个image弹出一个日历控件,然后选择完了自动收回去。我看别人的例子这么写的。也没有别的了 ,不知道为什么我这里就有错。谢谢了。
      

  4.   

    onclick="popUpCalendar(this, form1.txt_year, 'yyyy')" --->vs2005onClientlick="javascript:popUpCalendar(this, document.getElmentById('txt_year').value, 'yyyy')" 
    还有,txt_year如果是runat='server'的,那么要修改js为var yeartxt=document.getElmentById('<%=txt_year.ClientID%>').value;onClientlick="javascript:popUpCalendar(this, yeartxt, 'yyyy')" 
      

  5.   

    纠正:onClientlick-->onClientClick
      

  6.   

    如果你这个按钮没有用到向服务器端提交数据或者发生事件请求的话,请改用<img src="..." onclick="..." style="cursor: hand;" />
      

  7.   

    1 给image添加点击函数:
    Image1.Attributes.Add("onclick", "popUpCalendar(this.clientID, form1.txt_year, 'yyyy')");
    2 js脚本改成:
    popUpCalendar(parm1,parm2,parm3)
    {
       ... document.getElementById(parm1)
      ... 不知道parm2是干什么用的,根据实际情况来吧
    }