Editing a CSS style sheet for ASP.NET

I am looking to update a CSS file and save the changes. On my ASP.NET C# web page, I want the admin to have the ability to modify styles from the admin panel, such as colors, background colors, and font sizes.

For instance, I would like the admin to be able to choose a color and then click a button to apply the change. In the backend code, I want to access the CSS file at a specific location, make the necessary alterations, and then save the file.

Do you think this is achievable? I would appreciate any assistance you can provide on this matter.

Thank you in advance.

Answer №1

In my opinion, one effective approach is to store admin settings in a database and dynamically change the page's style using JavaScript when it loads. For instance, you can save the background color of the page in the database, then retrieve it upon loading and assign it to a string variable like 'Color.' Next, you can invoke a JavaScript method such as

setBackgroundColor(<%Color%>)
, which calls the following function:

function setBackgroundColor(color)
{
    document.getElementById("#bodyId").style.background = color;
}

This allows for dynamic styling changes based on stored admin settings.

Answer №2

To safely keep track of your CSS parameters, consider utilizing a structured database for storage with an admin interface for easy updating. Afterwards, develop an ASPX webpage that dynamically generates your desired style (setting its Response.ContentType to "text/css") and connect it using the following code snippet:

<link rel="stylesheet" href="DynamicStylePage.aspx" type="text/css" />

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

Recording Large Files in MySQL with C# Implementation

I am trying to record large files in MySQL using C#. The current code I have writes the file in parts, using a buffer size that matches the size of each part. However, when I attempt to write the entire file at once by increasing the buffer size to match t ...

The hamburger icon on the Bootstrap 4 navbar expands as expected, yet it fails to collapse back when

<head> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src=" ...

Bootstrap - A collapsed navigation button that remains fixed without the rest of the navbar

I'm currently working on a responsive drag and drop game that utilizes Bootstrap and jQuery UI. Within the game, I have implemented a collapsible navbar at the top of the page. To optimize space for buttons at the bottom, I am looking to hide the nav ...

Exploring the information within a subject

What is the process to access the id of a model nested within another model? model.py class Topic(models.Model): """ A topic that the user is learning about """ text = models.CharField(max_length=200) date_added = models.DateTimeField(auto ...

Set the position of bootstrap column content to be fixed

I have a bootstrap row with two columns and some offset. I am trying to make the last column have a fixed position so that it remains visible even while scrolling. This last column contains image content. Although I tried using the affix class provided by ...

Is there a way to create a dropdown menu that stretches across the entire page width when the burger menu is hovered over?

Is there a way to create a full-width dropdown menu that appears when the burger icon is clicked, while still maintaining the close function? (The dropdown menu and burger icon should transition smoothly when clicked) Here are the JavaScript functions for ...

Novice problem with the <div> tag

I am currently in the process of developing a website, and I have encountered an issue with the title not staying within the designated div box at the top of the page. <div style="width:1000px;height:40px;background:grey;border:3px solid;border-radiu ...

Issue with Ajax Call preventing animation in Google Chart Gauge on Google API

setInterval(function () { refreshGauge(); }, 5000); var chart1 = null; function refreshGauge() { $.ajax({ type: "POST", url: "Default.aspx/GetGuageData", data: '{}', contentType: ...

Ways to disregard the more recent dependency of a Nuget package

Encountering an issue with the Nuget package installation due to a dependency on an older version of Unity while a newer version is already in use. The specific package causing the conflict is NServiceBus Unity, which requires an older version of Unity th ...

Choose a Singular Item from an Irregular Array

Struggling through a problem that seems to be melting my brain, even though it shouldn't be this difficult. Let me try to sum up my question quickly! I'm dealing with an Array object that contains elements which are also Arrays. For instance: c ...

Activate the TextBox for editing through code

Currently, I am working on enhancing a multi-column listview to allow for cell editing. The objective is that when a user clicks on a selected cell, a TextBox should appear, allowing the user to change the cell content by typing text and confirming with th ...

Exploring LESS - improving CSS output by utilizing mixins for rule optimization

I've recently started experimenting with LESS. I decided to create rules for elements with numeric IDs, leading me to this code snippet: @myRule: {padding: 0;}; .myLoop(@c, @rules) when (@c >= 0) { .myLoop((@c - 1), @rules); &[id*=@{c ...

Arrangement of cards in a column

As someone who is new to working with CSS, Wordpress, and similar technologies, I am seeking assistance. I am struggling with creating card layouts. My goal is to achieve a layout similar to this, where the cards are displayed in two columns instead of ju ...

Can anyone suggest a method to customize the appearance of select options in Vue.js?

https://i.sstatic.net/qNov8.png Is there a way to customize the color and font of select options? I'm referencing this link for an example: . I attempted CSS modifications but they don't seem to be taking effect. ...

Animated CSS side panel

I'm currently working on creating an animation for a side menu. The animation works perfectly when I open the menu, but the problem arises when I try to animate it back closed. Is there a property that allows the animation to play in reverse when the ...

How to prevent redundancy in CSS styling

Exploring CSS on my own and have the following HTML structure: <style type="text/css"> #content { display: block; width: 250px; height: 50px; background-color: #330000; } /* pink */ #one, #two, #three, #four { height: 25px; width: 25px; float: left ...

Expiration of ASP.NET UpdatePanel

My request is being sent from an UpdatePanel and it's taking over 90 seconds to complete. I keep getting this timeout error: Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out. Is the ...

What steps can I take to correct this CSS code? I am looking to update the content using CSS

Here is the code I have for the specific page shown in the screenshot: https://i.sstatic.net/57o2Z.jpg I want to change 'Replay course' to 'Access course'. Can anyone help me figure out what I'm missing? a.course-card__resume { d ...

I am looking to send data to a checkbox using Python and the Selenium web-driver. What is the best

I am attempting to automate the process on this particular webpage by inputting data into a checkbox that has a unique @id. Even though I have tried utilizing code snippets I discovered online, my attempts keep falling short due to the element not being f ...

Stop iPad mobile Safari from truncating content with CSS

Encountering an issue with content being cut off on iPad devices. Even when the width exceeds the iPad's resolution, it seems strange that horizontal scrolling isn't automatically added instead of cutting off the content. If anyone has any sugg ...