|
-
Dec 21st, 2006, 04:12 PM
#1
Thread Starter
Member
[RESOLVED] chnaging Textbox Background color
Hi there I am having problems changing the backgrounf colour of a mobile textbox at runtime
This is my code
Protected Sub oblstRec_ItemSelect(ByVal sender As Object, ByVal e As System.Web.UI.MobileControls.ObjectListSelectEventArgs) Handles oblstRec.ItemSelect
Me.ActiveForm = frmRes
lblpartn.Text = e.ListItem.Item("PartNumber")
txtpartn.Text = e.ListItem.Item("PartName")
txtcon.Text = e.ListItem.Item("Condition")
txtloc.Text = e.ListItem.Item("Location")
txtquan.Text = e.ListItem.Item("Quantity")
txtval.Text = e.ListItem.Item("Valid")
If (txtval.Text = 0) Then
Me.txtval.BackColor = Drawing.Color.Aqua
Else
Me.frmRes.BackColor = Drawing.Color.Green
End If
End Sub
It tests if the data reterived for the txtval textbox is 0, if it is it should change the background coloyr to aqua and if not green
It does nothing, yet if i change the textbox name to the form name it will change the form background with this code just not the text box background
Anyone have any ideas it is driving me nuts
lee
-
Dec 21st, 2006, 07:56 PM
#2
Re: chnaging Textbox Background color
Are you playing with its background elsewhere in your code like setting it to white or so? If you place a new textbox out of nowhere on your form and try to change it's background in the same sub, is it working? Is the sub Protected on purpose?
-
Dec 22nd, 2006, 10:45 AM
#3
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there thanks for the reply,
I tried what your said
TexBox1.BackColor = Color.Aqua
But there is an error saying that Color is not declared
The textbox is added at design time and has no color set so it is white
The text box is poulated from an sql database then the data is check to see if it is 1 or 0 and the color of the text box set to red for 0 or green for one, ther are no errors in my origonal code but the colour is not changed
hope you can help
any more information just ask
lee
-
Dec 22nd, 2006, 10:53 AM
#4
Re: chnaging Textbox Background color
your project should already have a project wide imports
however if you don't for some reason just use the fully qualified name
System.Drawing.Color.AliceBlue
or add
Imports System.Drawing to the top of your code, then you can just use
color.aliceblue
-
Dec 22nd, 2006, 10:57 AM
#5
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there thanks for the fast reply
I did what your said and that fixed the Color error and there are no errors showing but the background still stays white does not change, if i change the form background it works ib the if stsment but not changing the textbox color that does nothing
any more ideas
I am using VS 2005 .net 2.0
lee
-
Dec 22nd, 2006, 10:58 AM
#6
Re: chnaging Textbox Background color
can you just try something simple like zen said and just do
TextBox1.BackColor = Color.AliceBlue
no if statement.. just see if infact you can change the color of the textbox.
-
Dec 22nd, 2006, 11:03 AM
#7
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there
Got rid of the if statment and put it in the main code, still doesnt do anything the textbox remains white background
Ive scored the internet and apparently this should work
I am however making a mobile asp.net web site and using vb.net
so the textbox is a mobile:textbox does this make a difference
lee
-
Dec 22nd, 2006, 11:19 AM
#8
Re: chnaging Textbox Background color
yeah I am sure the fact that it is a mobile control makes all the difference.
I haven't had the need to ever make a mobile asp.net website yet, however I did notice this comment in the documentation when I skimmed it
Note The ASP.NET ignores style (Font* and *Color) attributes when rendering to the adapter sets.
perhaps that has something to do with it?
-
Dec 22nd, 2006, 11:27 AM
#9
Thread Starter
Member
Re: chnaging Textbox Background color
hi there thanks alot i have read that tooo thats proberbly the problem just need to see if I can get round it some how, not sure how though
thanks
lee
-
Dec 22nd, 2006, 11:51 AM
#10
Thread Starter
Member
Re: chnaging Textbox Background color
Anyone have any ideas this is realy getting to me now
lee
-
Dec 22nd, 2006, 12:31 PM
#11
Re: chnaging Textbox Background color
 Originally Posted by lee2006
Anyone have any ideas this is realy getting to me now
lee
Hi,
You could try something like this;
VB Code:
<mobile:TextBox
runat="server"
id="id"
Font-Name="fontName"
Font-Size={NotSet|Normal|Small|Large}
Font-Bold={NotSet|False|True}
Font-Italic="{NotSet|False|True}
ForeColor="foregroundColor"
BackColor="backgroundColor"
Alignment={NotSet|Left|Center|Right}
StyleReference="styleReference"
Wrapping="{NotSet|Wrap|NoWrap}"
MaxLength="maxLength"
Numeric="{True, False}"
Password="{True, False}"
OnTextChanged="textChangedEventHandler"
Size="textBoxLength"
Text="Text"
InnerText>
</mobile:TextBox>
Hope it helps,
sparrow1
-
Dec 22nd, 2006, 12:37 PM
#12
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there thanks that looks like somthing I was just looking at but cant understand where the background color comes from in this line
BackColor="backgroundColor"
what is "backgroundColor" and how do i now what color is set
sorry i may be dimm
hope u can help
lee
-
Dec 22nd, 2006, 01:31 PM
#13
Re: chnaging Textbox Background color
 Originally Posted by lee2006
Hi there thanks that looks like somthing I was just looking at but cant understand where the background color comes from in this line
BackColor="backgroundColor"
what is "backgroundColor" and how do i now what color is set
sorry i may be dimm
hope u can help
lee
Hi,
Backgroundcolor means = Color.Red ore the color you wants.
Wkr,
sparrow1
-
Dec 22nd, 2006, 02:06 PM
#14
Re: chnaging Textbox Background color
actually that looks sort of like a markup language... not actual VB. my guess is you would have to use something like a hex color value or a defined name color value, and not the actual color.whatever structure... just like an HTML page.
-
Dec 22nd, 2006, 02:19 PM
#15
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there Trioed what you said but i need to be able to change the color from the VB code if statment, can see how this would work from the code you gave, if it does or you have any other ideas love to here them
thanks again
lee
-
Dec 22nd, 2006, 02:23 PM
#16
Re: chnaging Textbox Background color
 Originally Posted by lee2006
Hi there Trioed what you said but i need to be able to change the color from the VB code if statment, can see how this would work from the code you gave, if it does or you have any other ideas love to here them
thanks again
lee
Hi,
First things first, did my code helped you and could you change the backcolor of your textbox.
Wkr,
sparrow1
-
Dec 22nd, 2006, 02:31 PM
#17
Thread Starter
Member
Re: chnaging Textbox Background color
I understand from what you said and I have check that mobile web forms ignore the color element for any component e.g labels, textboxs, panales and so on. Dont know why but it does. The code you gave me, i understand adding the backColor = "backgroundColor" to the asp.net code but i did not understand where and how I assign the color to that variable, in what code and how, never done anything like that before, it has to be possible as manhy mobile apps have colored text areas.
thanks
let me know
lee
-
Dec 22nd, 2006, 02:41 PM
#18
Re: chnaging Textbox Background color
I found this note while I was looking around:
ForeColor, BackColor—These are used to set the foreground and background
colors for text display on a mobile device, for mobile phone
development, they are not very useful but because most mobile devices
are monochrome in nature.
so that, combined with the note in the MSDN documentation that control styles are ignored when rendering to adapter sets, you may simply just NOT be able to do this without a bunch of custom functionality.
-
Dec 22nd, 2006, 02:43 PM
#19
Re: chnaging Textbox Background color
Hi,
You should read this link about colors and Fonts that you can use into Mobile-Based Pocket PCs;
http://msdn2.microsoft.com/en-us/library/ms854925.aspx
Wkr,
sparrow1
-
Dec 22nd, 2006, 02:43 PM
#20
Re: chnaging Textbox Background color
man google works quick.. this very thread is already on page 4 when I did a search for this particular topic of chaning an ASP.NET mobile control backcolor.
http://www.google.com/search?q=asp.n...&start=30&sa=N
-
Dec 22nd, 2006, 02:56 PM
#21
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there thanks for all your help guess ill have to console my self to it cant be done then, checked out the document that you listed, was a great idea but it changes all the text boxs on all the form not just one and some of the language is not compatible with mobile devices not sure why
cant belive somthing so simple is so hard to do
very frustrating
thanks
lee
-
Dec 22nd, 2006, 04:14 PM
#22
Thread Starter
Member
Re: chnaging Textbox Background color
Hi there
thanks for all your help aprediacte lots
I set up the application as an asp.net website, removed the default asp.net file then added a mobile web file
This way it is not specific to any device in perticular will run on pda and phone. Least thats what I have been told.
Does this help
lee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|