快乐的生活……

导航

如何用客户端脚本触发服务器端控件的事件

问题:<asp:ImageButton id="WritConfirm" runat="server" ImageUrl="../images/icon_yes.gif"></asp:ImageButton>。这是服务器端控件。如何在客户端脚本 function doSelect(){ }中触发上个控件的click事件?

思归的答复是:you might need to change 'WritConfirm" to its client ID
function doSelect(){ document.getElementById('WritConfirm').click(); }

还有一个办法是:__doPostBack('WritConfirm','');

但是思归是不提倡用的:you shouldn't call __doPostBack directly since the function is generated by the ASP.NET engine, it could be changed in the next release.   if you want to, you should be calling Page.GetPostBackEventReference

posted on 2005-03-22 08:54  小诈  阅读(699)  评论(0)    收藏  举报