Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mobile style properties

Status
Not open for further replies.

kettch

Programmer
Mar 5, 2001
110
US
The asp.net mobile controls Label has a backcolor property. How do I get that to be passed through to the markup that gets sent to the client?

Consider this:
Code:
        <mobile:Label ID="Label4" Runat="server" BackColor="blue">Label Text</mobile:Label>

this color doesn't get applied client side, even if I go to the site with a desktop browser, which should be detected as supporting that sort of thing.

What am I doing wrong?

Thanks
 
At points like this I tend to start trying random things such as putting the RGB value in there (#0000FF) or maybe setting the relevent property in the code behind the page ("Label4.BackColor = Color.Blue" or something like it).

Do you know how hard it is for me to type Color not Colour?


Yet another unchecked rambling brought to you by:
Oddball
 
You should also check the source of the resulting page and see what HTML is actually rendered for that control (then it should point to being a browser or codign issue).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
The HTML that gets sent to the browser is has no color formatting whatsoever, I checked that. If I tell an element to use the title style, then it gets sent out as <b> and that works.
 
Where would I put that on a asp control? They don't support that. Besides, I'd kind of like to avoid any css because not all devices are going to support it.
 
kettch: my oversight. This is an interesting problem; setting the form's backcolor works:
Code:
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage"%>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"%> 
<HTML>
<HEAD>
<title>MobilePage Test</title>
</HEAD>
<body>
<mobile:Form runat="server" ID="Form1" BackColor="AliceBlue">
<mobile:Label ID="Label4" Runat="server"/>Label Text</mobile:Label>
</mobile:Form>
</body>   
</HTML>
..so not evident why the text is not responding (examples I have seen so far just set the Forecolor, BackColor straightaway with no issues). I'm going to continue doing a bit of background review to see if we can't come up with something.

 
Oh, I've been able to get the design time source to show up ok, it just never makes it into the markup that is sent to the client. I'm sure it's some setting somewhere that I've got messed up. Thanks for your help on this.
 
kettch: Try using the stylesheet.
Code:
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage"%>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile"%> 
<HTML>
<HEAD>
<title>MobilePage Test</title>
</HEAD>
<body>
<mobile:stylesheet id="myS1" runat="server"> 
  <mobile:Style Forecolor="red" Font-Name="Verdana" Name="myStyle"/>
</mobile:StyleSheet> 
<mobile:Form runat="server" ID="Form1">
<mobile:Label ID="Label4" Runat="server" StyleReference="myStyle">Label Text</mobile:Label>
</mobile:Form>
</body>   
</HTML>
..this seems to work ok.
 
kettch: Was just curious if the sytlesheet approach was something you observed in design time and yet did not make it to the markup. Let us know how this works out.
 
This is the stylesheet I am using:

Code:
<mobile:StyleSheet id="style1" runat="server"> 
  <mobile:Style Forecolor="red" Font-Name="Verdana" BackColor="blue" Name="someStyle"/>
</mobile:StyleSheet>

The forecolor is working and gets passed through as a <font> tag with colo="red". However, the BackColor doesn't make it.
 
kettch: Very interesting problem; of course with a regular asp:Label you get <span>..</span> elements in the rendered code but this is not happening with the Mobile control. As you pointed out above the background is not responding.

One shouldn't have to add <td> or <span> elements, etc since the Mobile:Label has the Background property. We're overlooking something here - if I stumble across it I'll post back.
 
kettch: One more note for today; this is the darndest problem I can remember. Everything you are doing appears correct; you get the same error if you transfer the style elements to a control panel where it should transfer attributes to objects within it, etc.

2 stars to whoever figures this one out -- I can't remember something so straightforward yet non-conforming.
 
Thanks for all of your help, I will keep poking around, and if I find out anything I will definitely post it.
 
One final note; I came across on several occassions a reference to the MobileControls in the <mobile:Form..></mobile:Form> tag (lost track of it); its not evident in any of the posts above, and also the following in the body tag:

<body Xmlns:mobile="
These two references may/may not be critical.

For those interested there is an excellent introduction for Mobile Phone web design (appears rather straight forward from a brief literature review). Click here for the pdf
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top