ASP.Net 4.5 Checking bootstrap and client side downloads

I have a fairly simple setup using the new ASP.Net 4.5 in a Web Forms solution. I've been using Twitter Bootstrap for almost a year and really enjoy the time it saves me and the consistency that it brings to the table. Some of their javascript methods are also quite useful. However, I had a problem with enabling some of the β€œnew methods” that seemed to be done in 4.5. Here is my main page:

<body>
    <form id="frmMain" runat="server">
        <asp:ScriptManager ID="smManager" runat="server">
            <Scripts>
                <asp:ScriptReference Name="jquery" />
                <asp:ScriptReference Name="bootstrap" />
            </Scripts>
        </asp:ScriptManager>
...

And here is the content of the test page:

<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="server">
    <asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Problem" ControlToValidate="txtTest" CssClass="error" SetFocusOnError="True" ToolTip="Problem">*</asp:RequiredFieldValidator>
    <asp:Button ID="btnTest" runat="server" Text="Check" CausesValidation="true" OnClick="btnTest_Click" /><br />
    <asp:TextBox ID="txtAnother" runat="server"></asp:TextBox>
    <asp:Button ID="btnOk" runat="server" CausesValidation="false" Text="No Check" />
</asp:Content>

Here is my Global.asax.cs file to show the ScriptReferences noted above:

protected void Application_Start(object sender, EventArgs e) {
    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

    ScriptManager.ScriptResourceMapping.AddDefinition(
        "jquery",
        new ScriptResourceDefinition {
            Path = "~/Scripts/jquery-1.8.2.min.js",
            DebugPath = "~/Scripts/jquery-1.8.2.js",
            CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js",
            CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.8.2.js",
            LoadSuccessExpression = "window.jQuery"
        }
    ); // Load jQuery

    ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.WebForms;

    ScriptManager.ScriptResourceMapping.AddDefinition(
        "bootstrap",
        new ScriptResourceDefinition {
            Path = "~/Scripts/bootstrap.min.js",
            DebugPath = "~/Scripts/bootstrap.js"
        }
    ); // Load Bootstrap

, , . "", - "Page.IsValid == false". , , .

, , :

<form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Problem" ControlToValidate="txtTest" CssClass="error" SetFocusOnError="True" ToolTip="Problem">*</asp:RequiredFieldValidator>
        <asp:Button ID="btnTest" runat="server" Text="Check" OnClick="btnTest_Click" /><br />
        <asp:TextBox ID="txtAnother" runat="server"></asp:TextBox>
        <asp:Button ID="btnOk" runat="server" CausesValidation="false" OnClick="btnOk_Click" Text="No Check" />
    </div>
</form>

, , , .

, bootstrap.js js. , ? bootstrap.js, . jQuery UI , .

, .

+5
1

All Articles