The combination of Asp.net and Bootstrap offers a powerful

I am facing an issue with using Bootstrap in my ASP.NET project. The page displays correctly on a desktop, but when I resize the page to mobile phone size, the navigation panel does not stay in dropdown position. Here is my code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"     Inherits="BootTest.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="navbar navbar-inverse navbar-static-top">

<div class="container">
<a href="#" class="navbar-brand">My Site</a>

<button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<div class="collapse navbar-collapse navHeaderCollapse">

<ul class="nav navbar-nav navbar-right">

<li class="active"><a href="#" >Home</a></li>
<li><a href="#">Blog</a></li>
<li class="dropdown">

<a href="#" class="dropdown-toggle" data-toggle="dropdown">Social Media<b  class="caret"></b></a>
<ul class="dropdown-menu">

<li><a href="#" >facebook</a></li>
<li><a href="#">twitter</a></li>
<li><a href="#" >google+</a></li>
<li><a href="#">instagram</a></li>

</ul>
</li>

<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>

</ul>
</div>

</div>

</div>
<div class="container">
<div class="jumbotron text-center">
<h1>Hello World</h1>
</div>
</div>


<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
    <p class="navbar-text">This is a test</p>
    <a class="navbar-btn btn-danger btn pull-right">Subscribe on YouTube</a>
</div>
</div>



    <script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script src="js/bootstrap.min.js" type="text/javascript"></script>
</div>
</form>
</body>
</html>

Answer №1

Here is the correct way to write it:

<button class="mobile-toggle" **data-trigger="click"** data-collapse=".header-menu">

Answer №2

Make sure that in your code, the data-target attribute corresponds to the id of the main navbar div element which should be '#bs-example-navbar-collapse-1'.

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JSON response is not being successfully passed in PHP Ajax form validation

I've been struggling to solve my code for the past few days but haven't had any success. I'm attempting to validate my login form using AJAX, however, it seems like there's an issue with my Jquery AJAX script. Every time I try, the con ...

Filtering with XML parsing

My XML file has the following structure - <?xml version="1.0" encoding="UTF-8"?> <prj:Flow xmlns:prj="url1" xmlns:com="url2" xmlns:ns2="url3" xmlns:con="url4" xmlns:ns0="url5" xmlns:ns1="url6" xmlns:ns3="url7"> <prj:str> &l ...

Looping through two elements at a time using jQuery

My current list structure looks like this: <div id="post-1" class="post"></div> <div id="post-2" class="post"></div> <div id="post-3" class="post"></div> <div id="post-4" class="post"></div> <div id="post ...

varying heights in bootstrap columns

My goal with utilizing the grid system of Bootstrap 3 is to achieve the following visual layout: View my envisioned image here. However, when using the normal row and col structure, I end up with a different result: See what I actually get here. Is there ...

Tips for submitting a form textarea input from CKEditor using AJAX

I am currently utilizing CKEditor, jQuery, and the jQuery form plugin. My objective is to submit the content of the CKEditor form through an Ajax query. Below is the code I have implemented: <form id="article-form" name="article-form" method="post" act ...

The controller remains unresponsive when attempting to activate the button on the webpage

I'm a beginner in frontend development and I'm currently working on a website that uses Thymeleaf. On this website, there is a div block with a button. Please take a look at the HTML code below, specifically the button at the last three rows. &l ...

The gaps separating rows

I'm struggling with getting my divs to look like a table, especially when it comes to highlighting a selected row. I've tried adjusting padding and margins without success. Does anyone have any suggestions on how I can achieve this effect? .ta ...

Adding margin to an HTML element causes the entire page to shift downward

Despite successfully applying margin to other elements, I encountered an issue with #searchbarcontainer where it causes the entire page to shift downward. My goal is to center it slightly below the middle of the page, but I'm struggling to find a solu ...

Incorporating invisible surprises into a fixed menu that reveal themselves as you scroll

I am working on implementing a top navigation and a sticky sub-navigation feature. The goal is to have the sticky nav become the top nav when the user scrolls down the page, similar to the functionality on this website - The issue I'm facing is with ...

Utilize the effectiveness of the Ajax Success Handler for retrieving a distinct JSON entity

One of the features I am currently using involves an Ajax command that enables me to query data from a local server. In order to ensure smooth execution, it is crucial for me to return a JSON object through the success handler. The specific structure of m ...

Is it necessary to verify JSON for duplicate keys before loading?

Currently, I am working on loading a text file that contains JSON formatted data. Before parsing the data, I need to validate it. Right now, I am using the following method to load the file: $.getJSON('dataFile', function(data) { } While this ...

Troubleshooting: Datepicker not appearing in Bootstrap

Here is the detailed markup for the datepicker component: <div class="form-group row"> <div class="col-xs-3 col-md-offset-9"> <label class="control-label">Pick Date</label> <div class="input-group date" id="dp3" data-d ...

What's the reason for the element not inheriting margins from its parent?

I am facing an issue with centering an h1 header within a .banner element. When I try to apply margin to the header, it appears to indent not from the top border of the banner, but rather from the nav element located above the banner. After inspecting the ...

What could be causing my custom WordPress route to not retrieve data from the database properly?

Within the following code snippet lies a custom endpoint that aims to extract data from the saic3_LibraryIndex database. <?php add_action('rest_api_init', function () { register_rest_route('libraries/v1', '/all', arra ...

Validation with Jquery in an ASP.NET C# login form utilizing a webservice

Hi there, I've been working on a login form in asp.net that should redirect to another page. To handle user validation, I created a webservice using jQuery but I'm facing an issue where the ajax data is returning undefined and the page is not red ...

What is the best way to line up three divs horizontally and center the contents inside each one?

I'm brand new to CSS and need some help simplifying things. I am trying to create 3 divs that are all the same size, placed next to each other, with centered content in each one. Currently, I have a central div with a rotating image, and on the left a ...

Automatically close the multiselect dropdown when the user interacts outside of it (varied scenario)

For those interested, check out this jsfiddle link: http://jsfiddle.net/jaredwilli/vUSPu/ This specific code snippet focuses on creating a multi-select dropdown feature. When a user chooses options from the dropdown and then clicks outside of the menu are ...

Generate an automatic "proxy" for ASP.NET MVC Controller to communicate with AngularJs service

Whenever I utilize an ASP.NET MVC controller with AngularJS, the majority of my controller functions consist of JSON results. When creating my AngularJS service, I find myself repeatedly writing similar code to handle GET or POST calls to my ASP.NET contro ...

Vue unable to load material icons

The icons npm package "material-icons" version "^0.3.1" has been successfully installed. "material-icons": "^0.3.1" The icons have been imported as shown below. <style lang="sass"> $material-icons-font-path: '~material-icons/iconfont/'; ...

Styling the large drop-down menu for Internet Explorer 7

Check out the code snippet at http://jsfiddle.net/jN5G4/1/ Is there a way to align the drop-down menu for "5 Columns" to match the alignment of the other drop-downs? After removing the <a href...> </a> tags from the 5 Columns list item, the d ...