在calendar中添加了一个ImageButton控件
ImageButton newAgenda = new ImageButton();
newAgenda.Attributes.Add("onClick", "javascript:alert('Hello,world');");控件中添加上面的代码可以执行,但如果添加:
newAgenda.Attributes.Add("onClick", "javascript:location.href='test.aspx'");
就不能执行了?

解决方案 »

  1.   

    newAgenda.Attributes.Add("onClick", "javascript:document.location.href='test.aspx';");
      

  2.   

    or:newAgenda.Attributes.Add("onclick", "window.navigate('test.aspx')");or:<a href="test.aspx">
    <asp:Image/>
    </a>
      

  3.   

    try this:
    newAgenda.Attributes.Add("onClick", "window.location.href('test.aspx');");
      

  4.   

    都试了,还是不行,客户端也能生成类似的代码,但就是不能执行,大家帮我看看,谢了
    <input type="image" src="image/Edit.gif" onclick="javascript:window.location.href='test.aspx';" style="border-width:0px;" /><input type="image" src="image/Edit.gif" onclick="javascript:document.location.href='test.aspx';" style="border-width:0px;" /><input type="image" src="image/Edit.gif" onclick="javascript:window.navigate('test.aspx');" style="border-width:0px;" />
      

  5.   

    奇怪:随便在页面放一个:Button1,在Page_Load中添加:
    Button1.Attributes.Add("onClick", "javascript:location.href='test.aspx';");运行,按Button1,页面闪一下,但把生成的html另存一个文件,直接打开html文件,按Button1按钮,可以实现页面跳转!