Selecting a navigation tab will change the displayed div, refresh the content, and set a default tab selection

Hey there, I'm diving into the world of ASP and CSS concepts and have run into a basic problem.

My navigation bar currently looks like this:

<li><a href="#Div1">Division 1</a></li><br>
<li><a href="#Div2">Division 2</a></li>

Below are my divisions:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<div id="TextBox">
    // a text box here which is common and should be displayed with both sections below
</div>

<div id="Div1" class="section">
// some button and text boxes here
</div>

<div id="Div2" class="section">
// some button and text boxes here
</div>
</updatePanle>

CSS file:

.section { display:none }
.section:target { display: block }

The CSS file section definition helps in selecting the correct divisions, but upon page load, only the top TextBox div is displayed.

I need div1 content to be displayed by default on page load. Also, when the textbox in the TextBox div has a value populated, the content refreshes and once again no div1 or div2 content is shown on the page.

The divs are defined within an update panel.

Any help would be greatly appreciated. Thank you!

Answer №1

It appears that the only viable option for this issue is to utilize javascript. Codex shared a similar workaround in another query.

HER suggested solution (tailored to fit your scenario) is

if (document.location.hash == "" || document.location.hash == "#")
    document.location.hash = "#SectionA";

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

Concealing specific DIV elements (unfortunately not nested)

Currently, I am dealing with pre-existing code that is automatically generated and needs to adhere to a specific format: <div id="TITLE1"></div> <div id="div-1"></div> <div id="div-2"></div> <div id="div-3"></d ...

The filter and search function in the table is malfunctioning

Recently, I developed a page designed for saving actors in an array and displaying them in a table. However, my attempt to add a search feature by name failed. If anyone has encountered a similar issue before and knows how to resolve it, please share your ...

The content within the div tag is not appearing after using the html() function

I'm facing an issue with an ajax call and .html(). In the javascript code below, I am using the geoloc callback to trigger an ajax call and update the content of a div. The id of the div can be either "result-shops-ajax-desktop" or "result-shops-aja ...

Utilizing CSS to adjust the position of a background image at its starting point

I'm looking to create a unique design for the sidebar on my Tumblr page, where the header has a curved shape while the rest of the sidebar has a squared-off look with 100% height. This design should flow seamlessly off the page without a visible foote ...

Show pip values within Nouislider as a numerical range

Here is the code I used to create a nouislider: <div id="slider"></div> <script> var slider = document.getElementById('slider'); noUiSlider.create(slider, { start: 0, step: 1, tooltips: false, connect: ...

jQuery not targeting absolute positioned duplicates of the <div>'s

(Please find the code link at the bottom of this question) I have been working on a radial menu for a web project. However, I've encountered an issue that has me stuck for hours now. No matter what I try, I can't seem to get any response from th ...

Employing jQuery to populate information into an input field, yet encountering an issue where the data is not being successfully transmitted to

On my page, there is a form with an input box <input name="bid_price" id="bid_price" class="form-control"> If I manually enter a value, it gets posted successfully But when I try to insert a value using jQuery, it doesn't get posted, even tho ...

Creating a three-tiered navigation menu using Bootstrap 4

I am struggling with adding a 3-level dropdown menu to my website. My HTML code seems correct, and I have added the necessary CSS styles, but the last dropdown menus are appearing in the wrong place. <li class="nav-item dropdown"> ...

Adjust the class based on the model's value in AngularJS

items = {'apple', 'banana', 'lemon', 'cat', 'dog', 'monkey', 'tom', 'john', 'baby'} html <div class="variable" ng-repeat="item in items">{{item}} </div> ...

What is the best way to scale an image to perfectly fit its container using CSS?

After starting the Freecodecamp course, I encountered a roadblock while working on one of the projects. Here is the current status of my project: https://codepen.io/otapadar/full/JjRaoex (I am aiming to replicate this website: https://codepen.io/freeCodeCa ...

What causes List<SelectListItem> to become null after submitting the form?

When attempting to display a RadioButtonList in Asp.Net MVC 3.0, I have created an extension method as shown below: using System; using System.Collections.Generic; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Html; using System.Linq.Expre ...

Incorporate row numbering feature into jQuery DataTables

Is there a way to have jQuery datatables generate a row number column in the first column, similar to a datagrid in VB? This is what I'm aiming for: If you have any insights on how this can be achieved, please share! ...

Develop a program using the local time of Barcelona as a reference

I'm having trouble with my code that is supposed to change the background and image based on the current hour in Barcelona. It doesn't seem to be working properly. JAVASCRIPT CODE var now = new Date(); var offset = now.getTimezoneOffset(); var ...

Add the onclick function to $(document).ready for applying the desired functionality

I've been trying to create a fading effect for 3 divs on my page, similar to the one in this example: http://jsfiddle.net/x4qjscgv/6/ However, I want the fade animation to trigger only when a user clicks a button. I attempted to use the document.getE ...

Ways to extract innerHTML content from a loaded element generated by using the .load() method

Check out the code snippet below: template.html : <div id="nav"> Welcome to Space </div> layout.html : <div id="content"> </div> $('#content').load("template.html #nav"); ale ...

Exploring Laravel's method for retrieving data from multiple tables in the controller

In an effort to make my jQuery call more dynamic, I have a controller with the following method: public function api(Request $request , $project_id){ return Program::where('project_id',$project_id)->get(); } This results in: [{"id":178," ...

Set Bootstrap column size to match a particular column

I am currently using BootStrap 4 and I am attempting to make a column's height equal to another column. Below is the code snippet I am working with: <div class="container" style="overflow:hidden"> <div class="row" style="overflow:hidden" ...

Check if the browser is not Google Chrome before running the code in JavaScript

Related Search: Finding a secure way to detect Google Chrome using Javascript? Using Javascript to identify Google Chrome and apply CSS changes Is there a JavaScript statement that can be used to execute code only when the user is not using Google ...

when the keyboard appears on mobile, ensure that the input element is in focus

Is there a way to automatically scroll the page/form to focus when a user clicks on an input field and the keyboard pops up? I want the input field to be displayed within the current view. I've attempted two solutions, but neither seems to be effecti ...

Parallel Bootstrap vertical grid layout

Struggling to articulate my objective, but bear with me. I am in the process of creating two bootstrap grids to house expanding text boxes. Refer to the image below for a visual representation; Desired Outcome Despite my efforts, the output from my code ...