I suggest NOT using .NET to style your form elements, but rather and external style sheet.
... using ids or classes to style your form elements. Firefox (I asume this is the Mozzila version your developing for) is much more capable when it comes to css if done according to standards.
like so....
-----
/* CSS */
.mybutton { color:red; background-url(/someImage.gif) }
-----
or
Any reason Y THIS IS HAPPENING???
Please post your code when asking this type of question.
senexom
Junior Poster in Training
54 posts since Jun 2005
Reputation Points: 11
Solved Threads: 0
1.But how can you use CSS style sheets to handle dynamic resizing of webcontrols.More like this code..
'Button Layer Adjustments
'Position : WIDTH AND HEIGHT
Dim Slayer1 As Integer = CInt(Session("widthforbuttons")) * 0.23
Dim Slayer2 As String = Slayer1.ToString
Dim Slayer3 As String
Slayer3 = String.Concat(Slayer2, "px")
BtnBlayer.Style.Add("WIDTH", Slayer3)
Dim Slayer4 As Integer = CInt(Session("widthforbuttons")) * 0.1
Dim Slayer5 As String = Slayer4.ToString
Dim Slayer6 As String
Slayer6 = String.Concat(Slayer5, "px")
BtnBlayer.Style.Add("HEIGHT", Slayer6)
BtnBlayer.Style.Add("TOP", "0px")
When I say that I suggest not using CSS in .NET, it means that use only when you have to, like dynamically resizing panels, etc. Does the above code not produce proper results in Firefox? Not to put you down, plus I don't know how your layout is done, but it's best practice to make your layout independent of your code, leaving it unaffected to code changes. CSS is extremely capable of stretching and wrapping and on a page in those dynamic conditions. (I'm no CSS guru, but have done some very dynamic layouts with it)
<asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server"
Text="Button" BackColor="#C0C0FF"></asp:Button>
Again avoid using style in .NET your code would look much cleaner and easier to maintain, your button will look nice if you use proper css. In your example get rid of BackColor property and define it in style tag...
senexom
Junior Poster in Training
54 posts since Jun 2005
Reputation Points: 11
Solved Threads: 0
You can use CSS with .NET. However, .NET will PRODUCE CSS for IE, not cross-browser CSS.
That's why it's best to code your OWN CSS, and then add class defiinitions via the Add() method of the Attributes collection of the particular server control.
In others words, "styles" are yet one more area where ASP.NET has screwed things up royally.
Always use "flow layout", always create your own internal or external stylesheet, and assign classes to server controls:
myControl.Attributes.Add("class","myCssClass");
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
If you're going to add styles "piecemeal", then yes, you have to use the Styles.Add method. My suggestion was to make complete CSS class definitions, then assign an entire "class" to your control.
No, you cannot have variables in CSS.
"Grid Layout" simply means "CSS absolute positioning". It's another case of Microsoft giving their own term for something that already existed, to presumably obscure the fact that they didn't invent it.
If you absolutely position everything, then when the user resizes their browser, nothing "moves". Most users expects things to "fit" their browser. Flow layout (CSS relative positioning", allows for elements to flow, within constraints, to fit the size of the browser.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
Yes, ASP.NET is a dual-edged sword when it comes to browser capabilities. Your solution is the right one. However...
A professional web developer knows about cross-browser issues, and doesn't need a runtime dll on the web server to try to FIX THINGS FOR HIM (or HER)!
I prefer to write strict XHTML. I prefer to have external style sheets. If I want a DIV, I'll use a DIV. If I want a TABLE, I'll write a TABLE. What I don't need is a mysterious "panel" control that will render a div or a table based on it's own misunderstandings of what browsers are capable of what.
That being said, when I do ASP.NET development, I use the bare minimum of ASP.NET Web Server controls. If I want a DIV, I use a pure HTML DIV.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37