Style properties are ignored by Mozilla browser...

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Style properties are ignored by Mozilla browser...

 
0
  #1
Jun 28th, 2005
PURPOSE
I'm trying to adjust the styles of buttons,textbox ....(More like height,width,text size) so that it looks good for each and every resolution,window size..

ISSUE
Whenever I change the attributes like background and size,While using Internet Explorer its working fine but in Mozilla its not working at all :rolleyes: For some reason all the styles for the webcontrol are ignored by the Mozilla browser.

Any reason Y THIS IS HAPPENING???

Thanks
Save White Tiger
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: Style properties are ignored by Mozilla browser...

 
0
  #2
Jun 28th, 2005
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) }
-----

<input type='submit' id='button1' name='button1' class='mybutton' runat='server' />
or
<asp:button id='button1' runat='server' cssclass='mybutton' />

Any reason Y THIS IS HAPPENING???
Please post your code when asking this type of question.
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Style properties are ignored by Mozilla browser...

 
0
  #3
Jun 28th, 2005
1.But how can you use CSS style sheets to handle dynamic resizing of webcontrols.More like this code..

  1. 'Button Layer Adjustments
  2. 'Position : WIDTH AND HEIGHT
  3.  
  4. Dim Slayer1 As Integer = CInt(Session("widthforbuttons")) * 0.23
  5. Dim Slayer2 As String = Slayer1.ToString
  6. Dim Slayer3 As String
  7. Slayer3 = String.Concat(Slayer2, "px")
  8. BtnBlayer.Style.Add("WIDTH", Slayer3)
  9.  
  10. Dim Slayer4 As Integer = CInt(Session("widthforbuttons")) * 0.1
  11. Dim Slayer5 As String = Slayer4.ToString
  12. Dim Slayer6 As String
  13. Slayer6 = String.Concat(Slayer5, "px")
  14. BtnBlayer.Style.Add("HEIGHT", Slayer6)
  15.  
  16. BtnBlayer.Style.Add("TOP", "0px")

2.This is a simple button...and when declared as an INPUT its working in both Mozilla Firefox..But when declared as a server control..its aint working in Mozilla..

  1. <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server"
  2. Text="Button" BackColor="#C0C0FF"></asp:Button>

When I view this button in MSIE ..its colored but when I view this button in Mozilla, its not colored rather the button goes back to its default view..
Save White Tiger
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 54
Reputation: senexom is an unknown quantity at this point 
Solved Threads: 0
senexom's Avatar
senexom senexom is offline Offline
Junior Poster in Training

Re: Style properties are ignored by Mozilla browser...

 
0
  #4
Jun 28th, 2005
Originally Posted by Letscode
1.But how can you use CSS style sheets to handle dynamic resizing of webcontrols.More like this code..

  1. 'Button Layer Adjustments
  2. 'Position : WIDTH AND HEIGHT
  3.  
  4. Dim Slayer1 As Integer = CInt(Session("widthforbuttons")) * 0.23
  5. Dim Slayer2 As String = Slayer1.ToString
  6. Dim Slayer3 As String
  7. Slayer3 = String.Concat(Slayer2, "px")
  8. BtnBlayer.Style.Add("WIDTH", Slayer3)
  9.  
  10. Dim Slayer4 As Integer = CInt(Session("widthforbuttons")) * 0.1
  11. Dim Slayer5 As String = Slayer4.ToString
  12. Dim Slayer6 As String
  13. Slayer6 = String.Concat(Slayer5, "px")
  14. BtnBlayer.Style.Add("HEIGHT", Slayer6)
  15.  
  16. 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)

Originally Posted by Letscode
  1. <asp:Button id="Button1" style="Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server"
  2. 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...

<asp:button id="Button1" style="background:#C0C0FF; Z-INDEX: 103; LEFT: 8px; POSITION: absolute; TOP: 48px" runat="server" text="Button" />
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Style properties are ignored by Mozilla browser...

 
0
  #5
Jun 28th, 2005
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:

  1. myControl.Attributes.Add("class","myCssClass");
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Style properties are ignored by Mozilla browser...

 
0
  #6
Jun 29th, 2005
Does the above code not produce proper results in Firefox?
Yes..The VB code is working in Firefox.I just displayed the code just to know whether anything similar can be achieved using CSS style sheets..

1.For some reason when you change the Background or Height or Width of a webcontrol in the designer,Its not affecting in Mozilla Browser BUT when the same change is done on the styles in HTML view ,IT WORKS FINE IN BOTH MOZILLA FIREFOX AND INTERNET EXPLORER.

2.Similarly ...In the code behind,
Button1.Attributes.Add("Backcolor", "#00C0C0") is not working
BUT
Button1.Style.Add("Background", "#00C0C0") is working fine in both the browsers..

Thanks for you help..

QUESTIONS

1.I'm now learning how to create CSS stylesheets and I'm planning to load a style sheet for each screen resolution.If you know any other way of doing it ,tell me.My application demands me to resize the controls for each resolution.

2.I know this is a long shot but its worth asking..Can you assign variables inside CSS stylesheets?

3.Whats the difference between using Flow layout and Grid layout.I read many articles that tells the reader to use Flow layout...
Save White Tiger
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 1,655
Reputation: tgreer is an unknown quantity at this point 
Solved Threads: 35
Team Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Style properties are ignored by Mozilla browser...

 
0
  #7
Jun 29th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2003
Posts: 781
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Solved Threads: 21
Team Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: Style properties are ignored by Mozilla browser...

 
0
  #8
Jun 29th, 2005
I would think the best way to get the job done would be to do a browser check and feed the correct snipet of CSS but thats me...
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.

Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Style properties are ignored by Mozilla browser...

 
0
  #9
Jun 29th, 2005
Yes..I'm planning to do something like that..
Create a complete CSS stylesheet definitions for each screen resolution and when the page loads i'm planning to check for the screen resolution and feed a particular CSS style sheet for that resolution..
Save White Tiger
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: Style properties are ignored by Mozilla browser...

 
0
  #10
Jul 1st, 2005
I just found out Y the properties are not working in Mozilla.
ASP.NET 1.1 doesn't recognize FireFox, the built-in WebControls will render down-level html.The <div/> tag will be replaced by a single-cell table, and a host of other changes which will distort the layout of the page..

SOLVING THE ISSUE
ASP.NET 1.1 can easily be told of the capabilities of other browsers through the web.config file. You can customize the regular expression used to evaluate the User Agent string.

If you want ASP.NET to support Firefox just paste this code within the <system.web/> node in the Webconfig file.

  1. <browserCaps>
  2. <case match="^Mozilla/5\.0 \([^)]*\) (Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))?">
  3. browser=Gecko
  4. <filter>
  5. <case match="(Gecko/[-\d]+)(?'VendorProductToken' (?'type'[^/\d]*)([\d]*)/(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*)))">
  6. type=${type}
  7. </case>
  8. <case> <!-- plain Mozilla if no VendorProductToken found -->
  9. type=Mozilla
  10. </case>
  11. </filter>
  12. frames=true
  13. tables=true
  14. cookies=true
  15. javascript=true
  16. javaapplets=true
  17. ecmascriptversion=1.5
  18. w3cdomversion=1.0
  19. css1=true
  20. css2=true
  21. xml=true
  22. tagwriter=System.Web.UI.HtmlTextWriter
  23. <case match="rv:(?'version'(?'major'\d+)(?'minor'\.\d+)(?'letters'\w*))">
  24. version=${version}
  25. majorversion=0${major}
  26. minorversion=0${minor}
  27. <case match="^b" with="${letters}">
  28. beta=true
  29. </case>
  30. </case>
  31. </case>
  32. </browserCaps>
Save White Tiger
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC