Search Results For : C#

Quick note on Web.config file

A quick note on Web.config file in the ASP.NET project. It is worth noting that the file is a XML File (read this for more info – )

One issue that hindered my process earlier was that the content in the value has special character it in, particularly, one of my SQL server’s password has a special character in it.

I would have to go and replace them accordingly. For instance, my password is <Password1& (note that < and ” is inclusive), i would have to change it to

You can refer to the list here –

Windows Phone 7 – Textbox On Focus Color

Was browsing around Stackoverflow and saw a question that someone asked, (WP7DEV) Textbox background changes when typing

Thought it will be useful for someone who needs it.

By default, a textbox on Windows Phone 7 will look at the one you see in the screenshot on the left, below, but when you were to focus on it, it will turn into slightly white-ish, as seen on the right.

Some of the scenarios for your development do not allow that and requires them to be the same. Written this quick guide in case someone needs it.

1. Attach a GotFocus event handler to the textbox you want to have the effect on.
2. Add this code in the method.

textBox2.Background = (SolidColorBrush)Resources[“PhoneTextBoxBrush”];
textBox2.BorderBrush = (SolidColorBrush)Resources[“PhoneTextBoxBrush”];

*Please remember to change textBox2 to the correct id of the textbox that you want the effect on.

For those of you who are curious where I get the Resources from, you can view a list of the available resources here :

You can download the solution here too:!2793&authkey=!ACBRpIRyDopM5Lo

Using Toggle Control to disable/enable idle detection – Windows Phone 7

Saw a question on Dream Build Launch on how can one use toggle control to disable / enable idle detection and from there, enable/disable it idle detection accordingly.

I believe he needed it in his setting page. Did up a quick demo.
















1. I used the toggle control from the silverlight toolkit for Windows Phone on codeplex (Can be found here : for the toggle control.

2. Do read this msdn article for

Things I did
1. Added the toggle controls in the toolkit into Visual Studio (if you have yet to do so)
2. Pull in the toggle controls and attached the checked event handler onto the control.
3. Add the following code (I included the method signature here).

private void toggleSwitch1_Checked(object sender, RoutedEventArgs e)

if (toggleSwitch1.IsChecked == true)
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;

You can download the demo file here :!2752&authkey=!AOBimFuXpsh6oog

WCF Completed Event firing more than once

The problem situation is stated in the title. =P

The “fix” to the problem is something real simple. I didn’t notice it when it happened to me the first time. This post is also posted to remind myself about it.

This is an example of a code with the problem.

public class WorkingArea{
Server.ServiceClient client = new Server.ServiceClient();

public WorkingArea()

private void btnCheck_Click(object sender, RoutedEventArgs e)
client.CheckCompleted += new EventHandler(Client_UpdateCompleted);

This code seems to be working fine. I have a Service which I declare it as client and everytime I click on the button Check, i attach the event handler and call the async method to run it. But wait, what went wrong is this.
“…..everytime I click on the button Check, i attach the event handler and call…….”

What happen is there will be alot handlers being attached to the client variable as times go by ( with the user clicking the button in our example ). The callback/comepleted event will increasingly happen with the button click in this example. With abit of moving of that line where you attach the handler. This will solve the problem.
“client.CheckCompleted += new EventHandler(Client_UpdateCompleted);”

I will recommend putting this in the constructor, loaded event handler or onNaviagtedTo. This will depends on what is the architecture of the application you are building.

If you have any question, please feel free to contact me at or use the contact page. Please visit the tutorials page for more tutorials from Microsoft Office to Windows Phone!

Windows Phone 7 – Removing Battery Indicator

Many a times, when we do a XNA game, we will want it to be full screen and hide the battery indicator. We will not want to show the battery indicator like this.

With Battery Indicator

With Battery Indicator

You can change it to remove the battery indicator by adding this line of code at the constructor where the game is initialized.
graphics.IsFullScreen = true;

Without Battery Indicator

Without Battery Indicator

You can download and view the sample here.
If you have any feedback, you can email me at