July 10th, 2008
Placing a web browser in your windows forms application could not be easier. All you need to do is place the WebBrowser control
on your Form in designer and then use the Navigate method on WebBrowser control to visit a web address. Here is a simple form I have created and handled the click event of button to navigate to a Url.
private void buttonGo_Click(object sender, EventArgs e)
{
webBrowser.Navigate(textBoxAddress.Text);
}
It does not take more than few seconds to get this going. IMO one of the easiest controls to work with.
2 Comments |
.NET |
Permalink
June 30th, 2008
.NET Framework provides String.IsNullOrEmpty() method which return true if the string is null or empty. It does not however take care of a string which only contains spaces. Often while persisting data we do not want to persist just empty strings. In past I have made this check before I let my data pass through. Today I thought of creating an extension method to do the same for me. Below is the code for the extension method which I have written in a StringExtensions class.
public static class StringExtensions
public static bool IsNullOrEmptyWhenTrimmed(this string s)
return !(s != null && s.Trim().Length > 0) ;
Here is an example on how this extension method can be used.
string x = " ";
if (x.IsNullOrEmptyWhenTrimmed())
Console.WriteLine("String is empty or null");
else
Console.WriteLine("String is NOT empty or null");
From now on I will be using this extension method whenever I have to check for empty strings. Short and sweet and useful

No Comments » |
.NET |
Permalink