The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Changing font color in Currency and Number controls
Posted: 07 Jul 09 2:09 PM
|
Hi guys, I'm a newbie to slx web development and I have an issue that I hope somebody can help me resolve. I have a few currency and number controls on a form that I would like to change the font for the number contained in the control depending on whether the number is positive or negative. The issue I am having is that when I access the controls properties I do not see the ForeColor property such as when you are using a textbox. I have been working with an example that I got from someone, but that does not seem to work very well. An example of the code is below:
System.Web.UI.WebControls.TextBox txtNumClosedLostQty = (System.Web.UI.WebControls.TextBox)form.numClosedLostQty.NativeControl; txtNumClosedLostQty.ForeColor = System.Drawing.Color.Red;
I thought this would work since I was under the assumption that TextBox was the base object for these other controls such as the number control but when I try to cast that number control back to a Textbox the app pukes. Any ideas for solving this would be greatly appreciated. Thank you. |
|
|
|
Re: Changing font color in Currency and Number controls
Posted: 07 Jul 09 2:29 PM
|
The Currency control is not a Derived control, but rather a Composite control. Instead of trying to cast it, you need use FindControl to get the actual TextBox.
Something along the lines of:
//This code is for illustration purposes, I have not tried this myself. TextBox theControl = form.numClosedLostQty.FindControl("CurrencyTextBox"); //I am not 100% on the Child control's name theControl.ForeColor = System.Drawing.Color.Red;
|
|
|
|
Re: Changing font color in Currency and Number controls
Posted: 07 Jul 09 2:46 PM
|
Thanks for the help Raul. I have tried the example you provided for me here. However my controls do not seem to expose that FindControl method so my app won't build as it says that FindControl does not exist. I doesn't even show up on intelliscence. |
|
|
|
Re: Changing font color in Currency and Number controls
Posted: 07 Jul 09 2:52 PM
|
I would suggest you try this on Visual Studio, not on SLX App Architect. Also, for debugging purposes it is always best to deploy without compilation so that you could test on Visual Studio.
I seldom make any Coding changes on SLX Via the App Architect !! |
|
|
|
Re: Changing font color in Currency and Number controls
Posted: 07 Jul 09 2:58 PM
|
Yes, I am working from in Visual Studio. We found out the hard way that Visual Studio and not App Architect was better environment to develop in. So I am developing in Visual Strudio and when I hit my control, FindControl is not one of the methods that show up on intellisence. I went ahead and build my project anyways just in case and ofcourse it puked . But I really appreciate taking your time trying to help out. Hopefully I can resolve, been working at it for a few days now. |
|
|
|
Re: Changing font color in Currency and Number controls
Posted: 07 Jul 09 3:34 PM
|
Try this:
Put in a break point on any event of the Page (OnLoad, PreRender), then add the control name to the Watch window and Manually explore its Controls property. Once you find the actual Text Box you should then be able to get a Find Control statement that works for you. |
|
|
| |
| |
|