gpt4 book ai didi

asp.net - 使用 ASP.NET 而非 MVC 的 Twitter Bootstrap

转载 作者:行者123 更新时间:2023-12-05 00:00:45 25 4
gpt4 key购买 nike

我在 ASP.NET Web 应用程序(不是 MVC)中工作了一段时间。我真的很想使用 twitter Bootstrap 框架。我认为它看起来很棒,并且已经为您完成了很多工作。我似乎无法让它与 ASP 服务器控件一起使用。我知道 css 可能正在尝试将 asp:Button 标记更改为 HTML 标记。我只是不知道如何让这些一起工作。我收到以下错误。

警告 2//文件位置:ASP.NET 运行时错误:基类包含字段“btnTest”,但其类型(System.Web.UI.HtmlControls.HtmlButton)与控件类型(System.Web. UI.WebControls.Button)。//文件位置 21 1 FalconFutbolClub

渲染站点以进行调试时,出现以下错误:

'Button' 类型的控件 'mainContentHolder_btnTest' 必须放置在带有 runat=server 的表单标记内。

我认为尝试使用 javascript 管理回发真的很烦人。我真的很想使用常规的 ASP 服务器控件,因此使用 ASP.NET Web 应用程序的全部原因。请帮忙。

编辑:代码。这是母版页和我的默认值。

ASP大师:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs"           Inherits="FalconFutbolClub.SiteMaster" %>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Falcon Futbol</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="What's in your toybox?">
<meta name="author" content="Pure Parties">
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap-responsive.css">

<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">

<style>
body {
padding-top: 85px; /* 60px to make the container go all the way to the bottom of the topbar */
}
</style>
<asp:ContentPlaceHolder ID="headerContentHolder" runat="server" />
</head>

<body>

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Falcon Futbol</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

<div class="container">
<div class="row">
<div span="12">
<asp:ContentPlaceHolder ID="mainContentHolder" runat="server" />
</div>
</div>
</div>



<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap-transition.js"></script>
<script src="assets/js/bootstrap-alert.js"></script>
<script src="assets/js/bootstrap-modal.js"></script>
<script src="assets/js/bootstrap-dropdown.js"></script>
<script src="assets/js/bootstrap-scrollspy.js"></script>
<script src="assets/js/bootstrap-tab.js"></script>
<script src="assets/js/bootstrap-tooltip.js"></script>
<script src="assets/js/bootstrap-popover.js"></script>
<script src="assets/js/bootstrap-button.js"></script>
<script src="assets/js/bootstrap-collapse.js"></script>
<script src="assets/js/bootstrap-carousel.js"></script>
<script src="assets/js/bootstrap-typeahead.js"></script>

<script type="text/javascript">
$('.carousel').carousel({
interval: 2000
})
</script>
</body>
</html>

掌握 C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FalconFutbolClub
{
public partial class SiteMaster : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
}

默认aspx:
<asp:Content ID="content1" ContentPlaceHolderID="headerContentHolder" runat="server">
<script type="text/javascript">

</script>
</asp:Content>

<asp:Content ID="content2" ContentPlaceHolderID="mainContentHolder" runat="server">
<div class="container">
<header class="jumbotron subhead" id="overview">
<h1>Falcon Futbol</h1>
<p>Event registration forms can be filled out here.</p>
<asp:Label ID="clickedTest" runat="server" />
</header>
<div class="span12">
<blockquote>
<p>Event registration form 1.</p>
<small>March 17, 2012</small>
</blockquote>
<div class="span4">
<asp:Button id="btnTest" runat="server" onclick="btnForm1_Click" Text="test" />
</div>
</div>
</div>
</asp:Content>

默认 C#:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.IO;

namespace FalconFutbolClub
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnForm1_Click(object sender, EventArgs e)
{
clickedTest.Text = "Clicked!";
}
}
}

最佳答案

看起来你自己回答了这个问题!只是为了跟进它 - 通常就在母版页的正文标记之后,您将有一个表单标记:

 <body>
<form id="form1" runat="server" >
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- omitted code from above -->
</div>
</div>

</form>
</body>

关于asp.net - 使用 ASP.NET 而非 MVC 的 Twitter Bootstrap ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9549623/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com