我对Bootstrap很新,但真正利用它。 我想要做的是获取一组按钮的点击事件。代码如下:
<div class="btn-group">
<button id="cmdBackupRestoreSource" runat="server" type="button" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown" onclick="CmdBackupRestoreSource_Click">Backup/Restore Source<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#" id="SqlSvr" runat="server" onclick="SqlSvr_Click">SQL Server (Default)</a></li>
<li><a href="#" id="CV" runat="server" onclick="CV_Click">Commvault</a></li>
</ul>
</div>
我正在查看的截图:
如何在C#中获取这些点击事件的代码?
答案 0 :(得分:1)
您需要使用onserverclick事件:
<div class="btn-group">
<button id="cmdBackupRestoreSource" runat="server" type="button" class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown" onserverclick="CmdBackupRestoreSource_Click">Backup/Restore Source<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="#" id="SqlSvr" runat="server" onserverclick="SqlSvr_Click">SQL Server (Default)</a></li>
<li><a href="#" id="CV" runat="server" onserverclick="CV_Click">Commvault</a></li>
</ul>
</div>
在您的代码中:
protected void CmdBackupRestoreSource_Click(object sender, EventArgs e)
{
//Your code goes here
}
protected void SqlSvr_Click(object sender, EventArgs e)
{
//Your code goes here
}
protected void CV_Click(object sender, EventArgs e)
{
//Your code goes here
}
onclick事件用于html控件中的客户端功能。