I am lost with something 'stupid'.
I am building my first spring application and I am trying to access css and jpg ressources files.
I rode many pages/forum and everyone's answer is "spring uses automatically what is in /static folder"
But I fail, and fail and fail again to include css and picture on my page. I tried so many things, now I feel totally lost (it's suppose to be an easy thing to do)
I use a WebSecurityConfigurerAdapter:
#Configuration
#EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter{
#Autowired
private UtilisateurUserDetailsService userService;
#Override
protected void configure(HttpSecurity http) throws Exception {
// #formatter:off
http.authorizeRequests()
.antMatchers("/","/index","/page1","/open/**", "/static/**", "/css/**", "/img/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/secure/page1")
.failureUrl("/login?error=true")
.permitAll()
.and()
.logout()
.logoutUrl("/logout")
.logoutSuccessUrl("/index")
.permitAll();
// #formatter:on
}
#Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/static/**");
}
#Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService);
}
#Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
In my application.property I have:
spring.resources.static-locations=classpath:static
There is my project arborescence:
And this is my index.html file:
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>My Quotes</title>
<link th:href="#{/css/main.css}" rel="stylesheet" >
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div th:if="${param.logout}" class="alert alert-info">Deconnected</div>
<div class="form-group">
<h1>Bienvenue dans MyQuotes</h1>
<div class="form-group">
<div class="button-group" sec:authorize="!isFullyAuthenticated()">
<a th:href="#{/login}" class="btn btn-outline-success topright">login</a>
</div>
<div class="button-group" sec:authorize="isFullyAuthenticated()">
<a th:href="#{/logout}" class="btn btn-outline-warning topright">logout</a>
</div>
</br> <span>Ici vous pouvez enregistrer et retrouver toutes vos
meilleurs citations et celles de vos amis </span> </br> </br> <a
th:href="#{/open/search}" class="btn btn-outline-warning">chercher
une quote</a>
</div>
</div>
</div>
<img th:src="#{img/img.jpg}"/>
</body>
</html>
Do someone can spot what I am doing wrong or what I am missing ?
Update your code to refer CSS as below and it should work.
<link th:href="#{/css/main.css}" rel="stylesheet" >
You can find more details here
Related
External CSS file doesn't work if I turn on auth with Spring Security.
#EnableWebSecurity
#Configuration
class SecurityConfig {
#Bean
fun security(http:HttpSecurity):SecurityFilterChain{
http
.formLogin()
.loginPage("/")
.failureUrl("/")
.and()
.logout()
.logoutSuccessUrl("/")
.and()
.authorizeHttpRequests()
.requestMatchers("/","/about_us").permitAll()
.anyRequest().authenticated()
return http.build();
}
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>BigBroHelp</title>
<link rel="stylesheet" type="text/css" href="../../static/css/final_form.css">
<link th:href="#{/css/start_page/final_form.css}" rel="stylesheet">
<link th:href="#{https://fonts.googleapis.com/css2?family=Jost:wght#500&display=swap}" rel="stylesheet">
<link th:href="#{/img/ответы_нейро_бошка.png}" rel="icon" type="image/png" style="width: 1000px">
<script th:src="#{/js/start_page/validation_counter.js}"></script>
</head>
<body id="body">
<div class="main">
<input type="checkbox" id="chk" aria-hidden="true">
<div class="signup">
<form>
<label for="chk" aria-hidden="true" id="reg_label">Регистрация</label>
<p id="count">0</p>
<input type="text" name="txt" placeholder="Логин" required="" id="reg_input_login" onclick="count()">
<!-- <input type="email" name="email" placeholder="Почта" required="">-->
<input type="password" name="pswd" placeholder="Пароль" required="">
<button onclick="count()">Зарегистрироваться</button>
</form>
</div>
<div class="login">
<form>
<label for="chk" aria-hidden="true">Войти</label>
<input type="email" name="email" placeholder="Логин" required="">
<input type="password" name="pswd" placeholder="Пароль" required="">
<button>Войти</button>
</form>
</div>
</div>
<div class="bigBro">
<div class="modal">
<h1>
Big Bro Help<br>
</h1>
<a class="btn" id="about_us" th:href="#{/about_us}">О проекте </a><br>
</div>
</div>
</body>
</html>
#EnableWebSecurity
#Configuration
class SecurityConfig {
#Bean
fun security(http:HttpSecurity):SecurityFilterChain{
http
.authorizeHttpRequests()
.anyRequest().permitAll()
return http.build();
}
}
If I leave any request permitAll an external CSS file works. But if I turn on auth, css file doesn't work.
Spring Boot version 3.0.2 (Spring Security 6.0.1)
Thymeleaf version 3.1.1
Ensure Spring Security does not require authentication for your CSS like this:
#Bean
fun security(http:HttpSecurity):SecurityFilterChain{
http
.formLogin()
.loginPage("/")
.failureUrl("/")
.and()
.logout()
.logoutSuccessUrl("/")
.and()
.authorizeHttpRequests()
.requestMatchers("/","/about_us").permitAll()
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
.anyRequest().authenticated()
return http.build();
}
Notice this added line:
.requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
I am trying to configure a .NET Core 7.0 project that uses MVC but would also like to support adding Blazor pages. I am having issues with the Program.cs file configurations and getting the app to use the blazor.server.js file. I have configured the app and file structure but upon running the app and trying to use a Blazor page I cannot get the functionality to work correctly.I created a demo app and tried to set up a counter but once the app runs the server.blazor.js file returns a 404.
I'm not certain what is being done wrong, and I can only seem to find guides for using .net 6.0 and the old syntax for configuring the Blazor portion.
The counter section, that is the Blazor component seems to do nothing, but the only error I get is onload the 404 for the blazor.server.js
Really at a loss as to why it wont work since all research suggest that this is possible
Below is all the code I think is relevant to the issue
program.cs:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// MVC
builder.Services.AddControllersWithViews();
// Add services to the container.
// Blazor
builder.Services.AddRazorPages();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
Component.razor:
#using Microsoft.AspNetCore.Components
<h3>Blazor Component in MVC</h3>
<button #onclick="Test" class="btn btn-dark">Click to get answer</button>
<br />
<div>#Data </div>
#code {
[Parameter]
public string Data { get; set; } = string.Empty;
private void Test()
{
Console.WriteLine("click");
Data = "Button Clicked";
}
}
Index.cshtml:
#using Microsoft.AspNetCore.Components
<h3>Blazor Component in MVC</h3>
<button #onclick="Test" class="btn btn-dark">Click to get answer</button>
<br />
<div>#Data </div>
#code {
[Parameter]
public string Data { get; set; } = string.Empty;
private void Test()
{
Console.WriteLine("click");
Data = "Button Clicked";
}
}
_layout.cshtml:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>#ViewData["Title"] - MvcBlazorSampleApp</title>
<base href="~/" />
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/MvcBlazorSampleApp.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">MvcBlazorSampleApp</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
#RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
© 2023 - MvcBlazorSampleApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<script src="_framework/blazor.server.js"></script>
#await RenderSectionAsync("Scripts", required: false)
</body>
</html>
Project file structure:
I have tried changing to configuration and tried looking for any resource for doing this in .NET 7, but I have not yet found a working solution. Only info I can find relates to .NET 6 and I cannot determine what I am missing in order for this to work.
Any ideas, resource or suggestions are welcome.
Take a look at this article which explains how to add Server Side Blazor to any AspNetCore web application.
https://www.codeproject.com/Articles/5321697/Building-a-Blazor-Server-Application-from-the-Web
I am making a login form for student and teacher. The code for login form is
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="TeacherLogin.aspx.cs" Inherits="E_T_Manager.TeacherLogin" %>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- start: Meta -->
<meta charset="utf-8">
<title>Login Page</title>
<meta name="description" content="Bootstrap Metro Dashboard">
<meta name="author" content="Dennis Ji">
<meta name="keyword" content="Metro, Metro UI, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
<!-- end: Meta -->
<!-- start: Mobile Specific -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- end: Mobile Specific -->
<!-- start: CSS -->
<link id="bootstrap-style" href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-responsive.min.css" rel="stylesheet">
<link id="base-style" href="css/style.css" rel="stylesheet">
<link id="base-style-responsive" href="css/style-responsive.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,latin-ext' rel='stylesheet' type='text/css'>
<!-- end: CSS -->
<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<link id="ie-style" href="css/ie.css" rel="stylesheet">
<![endif]-->
<!--[if IE 9]>
<link id="ie9style" href="css/ie9.css" rel="stylesheet">
<![endif]-->
<!-- start: Favicon -->
<link rel="shortcut icon" href="img/favicon.ico">
<!-- end: Favicon -->
<style type="text/css">
body { background: url(img/bg-login.jpg) !important; }
</style>
</head>
<body>
<div class="container-fluid-full">
<div class="row-fluid">
<div class="row-fluid">
<div class="login-box">
<form class="form-horizontal" id="frm" runat="server">
<div class="icons">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="UserName" ErrorMessage="Username is required." ForeColor="#CC0000">Username is required.*</asp:RequiredFieldValidator><br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Pwd" ErrorMessage="Password is required." ForeColor="#CC0000">Password is required.*</asp:RequiredFieldValidator>
</div>
<h2>Login to your account</h2>
<fieldset>
<div class="input-prepend" title="Username">
<span class="add-on"><i class="halflings-icon user"></i></span>
<asp:TextBox class="input-large span10" ID="UserName" runat="server" placeholder="Type UserName"></asp:TextBox>
</div>
<div class="clearfix"></div>
<div class="input-prepend" title="Password">
<span class="add-on"><i class="halflings-icon lock"></i></span>
<asp:TextBox class="input-large span10" ID="Pwd" runat="server" placeholder="Type Password"></asp:TextBox>
</div>
<div class="clearfix"></div>
<div class="input-prepend" title="Role">
<span class="add-on"><i class="halflings-icon lock"></i></span>
<asp:DropDownList ID="Roles" runat="server" class="input-large span10">
<asp:ListItem>Select Role</asp:ListItem>
<asp:ListItem>Teacher</asp:ListItem>
<asp:ListItem>Student</asp:ListItem>
</asp:DropDownList>
</div>
<div class="clearfix"></div>
<div class="button-login">
<asp:Button class="btn btn-primar" ID="T_S_login" runat="server" Text="Login" OnClick="T_S_login_Click" />
</div>
<div class="clearfix"></div>
</form>
<hr>
<h3>Forgot Password?</h3>
<p>
No problem, click here to get a new password.
</p>
</div><!--/span-->
</div><!--/row-->
</div><!--/.fluid-container-->
</div><!--/fluid-row-->
<!-- start: JavaScript-->
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery-migrate-1.0.0.min.js"></script>
<script src="js/jquery-ui-1.10.0.custom.min.js"></script>
<script src="js/jquery.ui.touch-punch.js"></script>
<script src="js/modernizr.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src='js/fullcalendar.min.js'></script>
<script src='js/jquery.dataTables.min.js'></script>
<script src="js/excanvas.js"></script>
<script src="js/jquery.flot.js"></script>
<script src="js/jquery.flot.pie.js"></script>
<script src="js/jquery.flot.stack.js"></script>
<script src="js/jquery.flot.resize.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/jquery.uniform.min.js"></script>
<script src="js/jquery.cleditor.min.js"></script>
<script src="js/jquery.noty.js"></script>
<script src="js/jquery.elfinder.min.js"></script>
<script src="js/jquery.raty.min.js"></script>
<script src="js/jquery.iphone.toggle.js"></script>
<script src="js/jquery.uploadify-3.1.min.js"></script>
<script src="js/jquery.gritter.min.js"></script>
<script src="js/jquery.imagesloaded.js"></script>
<script src="js/jquery.masonry.min.js"></script>
<script src="js/jquery.knob.modified.js"></script>
<script src="js/jquery.sparkline.min.js"></script>
<script src="js/counter.js"></script>
<script src="js/retina.js"></script>
<script src="js/custom.js"></script>
<!-- end: JavaScript-->
</body>
</html>
And the code behind is
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
namespace E_T_Manager
{
public partial class TeacherLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void T_S_login_Click(object sender, EventArgs e)
{
try
{
string connc = #"Data Source=KHAWAR-PC.\SQLEXPRESS;Initial Catalog=ETManager;Integrated Security=True";
SqlConnection con = new SqlConnection(connc);
con.Open();
string query = "SELECT * FROM Users WHERE UserName ='"+UserName.Text+"' and Password='"+Pwd.Text+"' and Roles='"+Roles.SelectedValue+"'";
SqlDataAdapter da = new SqlDataAdapter(query,con);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Session["New"] = UserName.Text;
Response.Redirect("Teacher.aspx");
}
else
{
Response.Write("<script>alert('Invalid UserName or Password or Role Type')</script>");
}
}
catch (Exception)
{
throw;
}
}
}
}
My problem is that I have implemented it for the login to teacher so far but I was failed to do so for student area. Can anybody tell me how to make user login either as a teacher or a student with sessions.
well, I am facing a problem in accessing label control of master page in its code behind file when i build solution it give error:
"the name 'lbllogin' does not exist in current context"
can anyone tell me how can i resolved this issue ....
this is my masterpage.master file code:
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Masterpage.master.cs" Inherits="Masterpage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>My WebSite</title>
<script type="text/javascript" src="JavaScript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function mainmenu() {
$(" #nav ul ").css({ display: "none" });
$(" #nav li ").hover(function () {
$(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(400);
}
, function () {
$(this).find('ul:first').css({ visibility: "hidden" });
});
}
$(document).ready(function(){
mainmenu();
});
</script>
<link rel="stylesheet" type="text/css" href="~/Styles/StyleSheet.css" />
</head>
<body>
<form id="form1" runat="server">
<div id="wrapper">
<div id="banner">
</div>
<div id="navigation">
<ul id="nav">
<li>Home</li>
<li>Review
<ul>
<li>Coffee</li>
<li>Coffee Shops</li>
<li>Coffee Brands</li>
</ul>
</li>
<li>Shop</li>
<li>About</li>
<li>Management</li>
<ul>
<li>Coffee</li>
<li>Users</li>
</ul>
</ul>
<div id="login" align="right">
<asp:Label ID="lbllogin" runat="server" Text="" ForeColor="White"></asp:Label>
<asp:LinkButton ID="LinkButton1" runat="server" ForeColor="White" OnClick="LinkButton1_Click" >LinkButton</asp:LinkButton>
</div>
</div>
<div id="content_area">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div id="sidebar">
</div>
<div id="footer">
<p>All rights reserved.</p>
</div>
</div>
</form>
</body>
</html>
and this is my code behined
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Masterpage : MasterPage
{
//protected global::System.Web.UI.WebControls.Label lbllogin;
//protected global::System.Web.UI.WebControls.LinkButton LinkButton1;
protected void Page_Load(object sender, EventArgs e)
{
lbllogin.Text = "error";
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}enter code here
}
Try accessing control using 'This' keyword..
e.g
This.lbllogin.Text = "error";
Hope this helps..
I have been working in ASP.NET Web Applications (not MVC) for a while at work. I really would like to use the twitter bootstrap framwork. I think it looks great and has a lot of the work already taken care of for you. I cannot seem to get it to work with ASP server controls. I know that the css is probably trying to change the asp:Button tag to an HTML tag. I just have no idea how to get these to work together. I get the following error.
Warning 2 //file location : ASP.NET runtime error: The base class includes the field 'btnTest', but its type (System.Web.UI.HtmlControls.HtmlButton) is not compatible with the type of control (System.Web.UI.WebControls.Button). //File location 21 1 FalconFutbolClub
When rendering the site to debug, I get the following error:
Control 'mainContentHolder_btnTest' of type 'Button' must be placed inside a form tag with runat=server.
I think it would be really annoying to try to manage postbacks with javascript. I really would just like to use regular ASP server controls, hence the whole reason of using ASP.NET Web Applications. Please help.
EDIT: Code. Here is the master page and my default.
Master 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">Home</li>
<li>About</li>
<li>Contact</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>
Master 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)
{
}
}
}
Default 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>
Default 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!";
}
}
}
Looks like you answered this yourself! Just to follow up on it - normally just after the body tag of a masterpage you would have a form tag:
<body>
<form id="form1" runat="server" >
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- omitted code from above -->
</div>
</div>
</form>
</body>