Posts

Showing posts from October, 2010

Internet explorer has restricted this webpage from running scripts...

When we open an XML file from local computer, I get the following error message: "In order to protect your security, Internet explorer has restricted this webpage from running scripts or ActiveX controls that could access your computer"
Which could be quite irritating if it is a large document or if you use the '+' often.
Solution: To resolve this go to Tools>Internet Options>Advanced and check the following: Allow active content to run files in my Computer Allow active content from CDs to run on my Computer.

Royal TS - remote desktop tool

I had been using RDC available in Windows for a long time and didn't actually found a problem with it until the day when I had to connect to half a dozen virtual machines - all of them having long, hard to remember auto generated passwords.
Enter Royal TS. It's just the first day of using it and I am already thanking my stars. (Got to know about this tool just by chance on of the manager's computer).
http://code4ward.net/main/
The current version are shareware with limited features, but the version 1.5 is full featured free version: http://www.code4ward.net/main/RoyalTS/Download/StatisticandpreviousVersions.aspx
Enjoy!

LINQ – fetching controls on the WinForm

Image
Let us take a simple example, but a useful one. We start with a form, having 3 text boxes and a button. The button validates whether all the text boxes are filled up or not (a common business case).We want to color background of the textboxes Red if they are empty:

var textBoxes = from tBox inthis.Controls.OfType<TextBox>()
where tBox.Text.Trim() == ""
select tBox;
foreach (TextBox tbox in textBoxes)
{
tbox.BackColor = Color.Red;
}


We get the same result as before. Building upon this, right now we get all the text boxes but what if we want to check only the visible text boxes? We should be able to achieve it by adding ‘tBox.Visible == true’ in the LINQ query. Which brings us to the question, how do we add AND condition in LINQ? (along the way let’s add Enabled condition as well)

var textBoxes =
from tBox inthis.Controls.OfType<TextBox>()
where tBox.Text.Trim() == "" &&
tBox.Visible == true &&
tBox.Enabled == true
select tBo…

Checking from Live writer

Image
Testing..1..2..3!Image check…