如何在ASP.Net中的asp:Button中放置一个Bootstrap组件?

时间:2016-08-15 19:55:18

标签: c# asp.net twitter-bootstrap aspbutton

如何添加此Bootstrap组件代码,这是一个搜索栏:

<div class="row">
    <div class="col-lg-6">
        <div class="input-group">
          <input type="text" class="form-control" placeholder="Search for...">
          <span class="input-group-btn">
            <button class="btn btn-default" type="button">Go!</button>
          </span>
        </div><!-- /input-group -->
    </div><!-- /.col-lg-6 -->
</div><!-- /.row -->

在旧的asp.net代码中:

<asp:Panel ID="altHeader3SearchPanel" runat="server" DefaultButton="">                                       
<div class="container-inline" id="search">
    <div class="form-item" id=
    "edit-search-theme-form-1-wrapper">
        <label for=
        "edit-search-theme-form-1">Search this
        site:</label> <asp:textbox class="form-text" id=
        "edit_search_theme_form_1" maxlength="50"
        name="search_theme_form" runat="server" size="15" title=
        "Enter the terms you wish to search for."
        type="text" value="" />
    </div>
    <asp:Button runat="server" ID="edit_submit" CssClass="form-submit" Text="" />

到目前为止,我尝试的所有内容都给了我错误应用程序或解析错误...

1 个答案:

答案 0 :(得分:0)

您只需要将html控件替换为服务器控件。

FYI :如果要在用户按Enter键时触发点击事件,则需要将按钮控件ID设置为DefaultButton。

<asp:Panel ID="altHeader3SearchPanel" runat="server" DefaultButton="GoButton">
    <div class="row">
        <div class="col-lg-6">
            <div class="input-group">
                <asp:TextBox class="form-control"
                    ID="edit_search_theme_form_1"
                    name="search_theme_form"
                    runat="server"
                    placeholder="Search for..." />
                <span class="input-group-btn">
                    <asp:Button ID="GoButton" runat="server" 
                       CssClass="btn btn-default" Text="Go" />
                </span>
            </div>
        </div>
    </div>
</asp:Panel>