"Encountering a glitch with masterpage.cs in Aspx.net and C#

Currently facing a perplexing issue while developing a website using aspx.net and c#. The following code snippet is on my masterpage:

protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Request.Url.AbsolutePath == "/Pages/Overzicht.aspx")
        {
            pagOverzicht.Attributes.Add("class", "active");
        }
        if (HttpContext.Current.Request.Url.AbsolutePath == "/Pages/Defeault.aspx")
        {
            pagPackage.Attributes.Add("class", "active");
        }
        if (HttpContext.Current.Request.Url.AbsolutePath == "/Pages/page1.aspx")
        {
            pagToevoegen.Attributes.Add("class", "active");
        }
        if (HttpContext.Current.Request.Url.AbsolutePath == "/Pages/page2.aspx")
        {
            pagWijzigen.Attributes.Add("class", "active");
        }

The goal is to make the current page active. It works in the test environment but not when published on the server.

Tried hitting ctrl+f5, but no luck. Any ideas why it's not working?

Answer №1

Ensure that the CSS class file has been successfully uploaded and remember to clear the cache. You can check if the file is already present using Firebug or Chrome Dev Tools.

Answer №2

Try replacing the equal operation with HttpContext.Current.Request.Url.AbsolutePath.Contains("/Pages/Overzicht.aspx"). – commented by user th1rdey3, 15 hours ago

After implementing this change, everything started working perfectly for me!

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

Creating a heading transition that moves from the bottom to the top with CSS

I am looking to add an animation effect to the H1 element in my program. I want it to smoothly appear from the bottom hidden position using a CSS transition when the page loads. How can I achieve this? Additionally, I need the height of the bounding elemen ...

Position two div elements so that the second div expands to occupy the entire available space

I am struggling with aligning two divs within a container div, one on the left and one on the right. I am using flexbox for alignment purposes, as shown in the code snippet below. .box { display: flex; align-items: center; just ...

Differences between using CSS properties and AngularJS filters:CSS properties

When working on an angularjs application, one task may be to convert a string to uppercase. There are 2 options available to achieve this, both yielding the same result. However, it is important to consider the scenarios in which one option may be preferre ...

Designing a Curved Stepper Component in the Shape of an S

I've been attempting to create a custom stepper component with an S-curve shape using React, but so far I haven't been successful. I even tried utilizing the MUI Stepper component and experimented with pure HTML and CSS, but couldn't achieve ...

Locate the element that contains the text stored in a variable

let example = row["item_no"]; The variable 'example' now stores the item number, and I am looking to locate a row on the page that contains this specific item number. However, my goal is to find this row using the variable name 'example&apo ...

Is there a way to determine if a table cell contains overflowing text compared to another cell?

https://i.sstatic.net/IYafA.png Is there a way to detect if the content of the fourth td overflows from the second td? I am looking for a method to determine which td has overflowed text and identify which td's text is overflowing. What approach ca ...

Anticipated the presence of a " (" in the EF-generated query

The SQL query below is executed on a MySQL Server 5.7: SELECT `t`.`c`, `t`.`Id`, `t0`.`Id`, `t0`.`Bio`, `t0`.`Image`, `t0`.`Name`, `t0`.`Follower_id`, `t0`.`Followed_id` FROM ... An error occurs when running this query: Error Code: 1064. ...

Path for the Ajax Control Toolkit HTMLEditorExtender AjaxFileUpload

I am currently facing an issue where I cannot save an image to a local path in my project, as I will not be deploying it on a server. I am struggling to determine the correct path for the file upload: Protected Sub htmleditorextender_ImageUploadComplete(s ...

The gap between list items(`<li>`s)

Feeling a bit perplexed here. I'm working on creating a page to showcase images. My goal is to have 5 images displayed per row, with maximum spacing when the window is at its widest (~950 px). However, as the window size decreases, I want the images t ...

Handling Many-to-Many Relationships in EF Core with C# Discord Bot

Recently, I've ventured into using Entity Framework Core to construct a database for Guilds (also known as Discord Servers) and Users, leveraging the Discord.NET Library. Each Guild can have multiple users, and each user can belong to numerous guilds. ...

Use CSS specifically for codeigniter viewpage

I am unsure if it is possible, but I would like to load CSS and JavaScript within a view page instead of on include.php. Currently, the CSS file is loading on include.php and it is working correctly. What I want to achieve now is to load it directly inside ...

New Feature in Bootstrap4: Navigation Bar Alignment Shift to the Left

I need help aligning my links to the right side of the page I attempted to use mr-auto but it was not effective <body> <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top mr-auto mt-2 mt-lg-0"> <a class="navbar-brand" hre ...

Styling CSS variables uniquely

I have limited knowledge of HTML and CSS, so I am unsure how to search for a similar post on StackOverflow. My apologies if this is a duplicate question. I am looking to achieve the following: margin-horizontal { margin-left: value; margin-right: va ...

Guide to aligning a URL in an HTML file

Greetings all, I'm new to HTML and struggling with how to center a URL on my webpage. For example: <a href="http://www.google.com"> Click Here to Open Google </a> I attempted using the tag and the STYLE attribute but without success. ...

Aligning text fields and text areas is not consistent

Seeking a solution to align two input fields side by side, with a textarea directly below them form ul { list-style: none; text-align: center; } form ul li { display: inline-block; margin-left: auto; margin-right: auto; } #nameform, #emailform ...

Try incorporating a variety of colors to enhance the appearance of your paper-menu in Polymer 1

I'm currently working on creating a customized menu using Polymer 1.0. This is how my menu structure looks like: <paper-menu> <template is="dom-repeat" items="{{menu}}" as="item"> <paper-item> <div>{{item.title}}</div& ...

Storing live data in an external database using asp.net

I'm currently following along with a tutorial that is guiding me in creating a dynamic data website. However, all the tutorials I've come across refer to using a local file-based database. I am in need of incorporating an external data model ins ...

Troubleshooting Vue.js rendering problems on Safari_BROWSER

I'm encountering a strange issue with my portfolio website, which is built using Vue and Laravel. The problem arises specifically in Safari - the project thumbnails don't display until the browser window is resized. Here's the relevant code ...

Creating dynamic CSS classes with SCSS/SASS

Recently, I encountered a scenario where I needed to automate the creation of a series of CSS classes by utilizing a mixin. This led me to ponder if there is a dynamic approach to achieve this. Essentially, the classes I have are structured as follows: . ...

Add the cordova plugin multi-image-picker with the following command

onDeviceReady: function() { window.imagePicker.getPictures( function(results) { for (var i = 0; i < results.length; i++) { alert('Image URI: ' + results[i]); } }, function ...