Is it possible to edit the style sheet from the codebehind?
I am having some issues with a gridview expanding in width when I click to update some row information. The gridview expands outside of the container and makes it extremely difficult to read. I am hoping that when I click the update button I can catch the row command and execute some code to edit the style sheet.
8 replies to this topic
#1
Posted 12 August 2010 - 08:26 PM
|
|
|
#2
Posted 12 August 2010 - 10:43 PM
Is this your site or a site your viewing?
You can edit the css of a current page your viewing using a firefox addon Web Developer
Warning:
The Web Developer Fire Fox add-on has shown increased amounts of dependency, when removed some users are often followed by great depressive moods.
Also... if it's your own site... why can't you just modify the css... so I'll assume it's not.
You can edit the css of a current page your viewing using a firefox addon Web Developer
Warning:
The Web Developer Fire Fox add-on has shown increased amounts of dependency, when removed some users are often followed by great depressive moods.
Also... if it's your own site... why can't you just modify the css... so I'll assume it's not.
#3
Posted 13 August 2010 - 03:32 AM
Its a web application I am making.
#4
Posted 13 August 2010 - 04:00 AM
In C#...
>>>>execute some code to edit the style sheet.
Rather just create multiple classes...
In the example below I have four stylesheet (css) classes: btn, green, red, blue
>>>>execute some code to edit the style sheet.
Rather just create multiple classes...
In the example below I have four stylesheet (css) classes: btn, green, red, blue
protected void [COLOR=RoyalBlue]Page_Load[/COLOR]([COLOR=RoyalBlue]object [/COLOR]sender, [COLOR=RoyalBlue]EventArgs [/COLOR]e)
{
[COLOR=RoyalBlue]Button [/COLOR]btn = ([COLOR=RoyalBlue]Button[/COLOR])FindControl("[COLOR=Red]btn1_ID_OF_ASP_BUTTON[/COLOR]");
if(btn != [COLOR=Green]null[/COLOR])
{
if(btn.[COLOR=DarkOrchid]CssClass [/COLOR]== "[COLOR=Red]btn green[/COLOR]")
{
btn.[COLOR=DarkOrchid]CssClass [/COLOR]= "[COLOR=Red]btn red[/COLOR]";
}
else
{
btn.[COLOR=DarkOrchid]CssClass [/COLOR]= "[COLOR=Red]btn blue[/COLOR]";
}
}
}
#5
Posted 13 August 2010 - 04:19 AM
That is a wonderful idea and I may use that for something else later. My issue is that what I need to edit is just a class that is used by a DIV from an external style sheet. The problem is I can't access that DIV or the style sheet class from the codebehind at the moment.
#6
Posted 13 August 2010 - 04:36 AM
>>The problem is I can't access that DIV or the style sheet class from the codebehind at the moment.
Talking about
Which is also why I wrote "btn1_ID_OF_ASP_BUTTON", keyword was the "asp", had to be an asp:Control... (button, image, label, textbox,panel, placeholder...any).
Whats the problem with "cannot access the style sheet class from the codebehind at the moment"... I get the problem with the DIV, but the StyleSheet?... You're not supposed to access the style-sheet file itself from code behind, no reason to do so either... You create "access to it" by adding this in the .aspx file:
Talking about
<div> What-ever /<div>Switch it to a
<asp:Panel> what-ever /<asp:Panel>then you can grant access to it with ease.
Which is also why I wrote "btn1_ID_OF_ASP_BUTTON", keyword was the "asp", had to be an asp:Control... (button, image, label, textbox,panel, placeholder...any).
Whats the problem with "cannot access the style sheet class from the codebehind at the moment"... I get the problem with the DIV, but the StyleSheet?... You're not supposed to access the style-sheet file itself from code behind, no reason to do so either... You create "access to it" by adding this in the .aspx file:
<link href="Sheets/Main.css" type="text/css" rel="stylesheet" />Note: Define "access to it"... :)
#7
Posted 13 August 2010 - 04:42 AM

~facepalm~
The magic bullet here was one little tiny bit of code in my css container class.......
overflow:auto;
~sigh~ Sorry, but thanks for the help. It was nice to learn about the Cssclass trick that ManyTimes posted.
#8
Posted 13 August 2010 - 05:42 AM
ManyTimes said:
.....Whats the problem with "cannot access the style sheet class from the codebehind at the moment"... I get the problem with the DIV, but the StyleSheet?... You're not supposed to access the style-sheet file itself from code behind, no reason to do so either... You create "access to it" by adding this in the .aspx file:
<link href="Sheets/Main.css" type="text/css" rel="stylesheet" />Note: Define "access to it"... :)
What I meant was being able to access the style sheet and edit it on the fly from the codebehind. Although, I solved the problem I started out to solve I would like to know if this is possible.
#9
Posted 13 August 2010 - 08:04 AM
It is possible to create a file on the fly; hence also a file with the extension ".css", with the text-format you want it to have, hence also a stylesheet-format. :)
But anyways, multiple classes should do the trick...
But anyways, multiple classes should do the trick...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top










