Want to edit things like DIV size, color, positioning (absolute), height/width etc.
-
Could you provide some more details please?knut– knut2009-04-22 15:05:06 +00:00Commented Apr 22, 2009 at 15:05
-
Clarification: do you want to edit an individual element's style, or do you want to change the CSS applied to the page in general?Dan Lew– Dan Lew2009-04-22 15:05:10 +00:00Commented Apr 22, 2009 at 15:05
4 Answers
You can just output the CSS like any other with Response.Write or the <%= someValue %> methods.
Here are some of the other methods: http://cfouquet.blogspot.com/2006/06/making-dynamic-css-content-with-aspnet.html
Comments
If by "on the fly" you mean while the user is interacting with the page then you're going to need to use some javascript. I suggest learning jQuery as it provides an easy and effective way interact with the DOM.
Comments
Ryan, you may want to look into Themes if you want to change the appearance of your site based on user preferences (Learning about Skins can help as well but master themes first). This is really the right approach in the ASP.NET model unless you are looking just to adapt some specific output to certain data conditions.
Comments
I'm not sure of what you're trying to do with the information given, but to add css on the fly you can use jQuery to add the class to an element with those certain specifications.. you can have jquery wait in the background for something to happen on the client and just add the class with that certain style
Example:
<style>
p { margin: 8px; font-size:16px; }
.color { color:blue; }
</style>
<script>
$(document).ready(function(){
$("#button1").click(function(){
$("p:last").addClass("color");
});
</script>
<p>Hello</p>
<p>and</p>
<p>Goodbye</p>