<div class="buttonRight"><asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"/></div>
向下呈现
<div class="buttonRight">
<input type="submit" name="_$_$pc$pc$tabTO$_$uc0$popupSelectCompetition$btnOK" value="OK" id="____pc_pc_tabTO___uc0_popupSelectCompetition_btnOK" style="width:68px;" /></div>
我需要在该按钮上调用一些javascript而不改变其行为。我尝试使用OnClick asp属性,但这似乎是用于回调调用服务器代码,而不是通过javascript钩子传递给渲染的html。
我也不明白input
type='submit'
对我的影响。
答案 0 :(得分:2)
将您的客户端代码添加到 OnClientClick 属性:
<div class="buttonRight">
<asp:Button ID="btnOK" runat="server" Text="OK" Width="68px"
OnClientClick="alert('client side scripts here');"/>
</div>
用于服务器端事件的OnClick属性。
或者将onclick属性添加到您的控件中,就像代码背后的那样:
btnOK.Attributes.Add("onclick", "alert('client side scripts here');");