5

你们有在基本 asp.net 表单上工作的引导组件的示例(按钮后面有代码,获取下拉选择值等)吗?

我真的不知道如何使它工作。

4

2 回答 2

9

As long as you have an understanding of how ASP.NET server controls render in HTML

example:

This server control:

<asp:Button ID="Button1" runat="server" CssClass="btn" Text="Button 1" />

Renders to this HTML:

<input type="submit" class="btn" id="Button1" value="Button 1" name="Button1">

then you're on your way to using bootstrap with ASP.NET webforms

The CssClass="btn" is all you need to style the button with bootstrap.

Paste the markup below in your .ASPX page to see an example

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" CssClass="btn" Text="Button 1" />
    </div>
    </form>
</body>
</html>

edit:

You can turn any standard HTML control into a server control by adding runat="server" and then add click event handlers server side.

HTML:

<a id="actionLink" runat="server">Action</a>

Code-Behind:

protected void Page_Load(object sender, EventArgs e)
{
    actionLink.ServerClick += new EventHandler(actionLink_ServerClick);
    ...
}

void actionLink_ServerClick(object sender, EventArgs e)
{
    ...
}

Rendered Anchor Tag:

<a id="actionLink" href="javascript:__doPostBack('actionLink','')">Action</a>

This should get you what you need to implement server clicks on those button dropdown and radio bootstrap controls.

于 2012-04-17T18:51:07.193 回答
0

GitHub 上的 Pedro Fernandes 提供了几乎完整的 ASP.NET 引导控件集,但不确定许可证:

https://github.com/cr1t/BootstrapControls

它仅支持 2.3.0 版本。将其转换为 3.0 应该不难。

于 2014-02-01T01:11:22.763 回答