Tag - .NET

How to convert SqlDataSource to DataTable and DataView in C#.NET

Sometimes I want to use SqlDataSource  returned data programmatically and here is how you can do this,In this example I will assume that SqlDataSource  ID is SqlDataSource1 which is the default ID:DataSourceSelectArguments args = new DataSourceSelectArguments(); DataView view = SqlDataSource1.Select(args) as DataView; DataTable dt = view.ToTable();

How to check SQL Server database is exists using C#.NET

The following method using sys. schema and views such as sys.databases and sys.tables.As we know that the old style sysobjects and sysdatabases and those catalog views have been deprecated since SQL Server.private static bool CheckDatabaseExists(string connectionString, string databaseName) { string sqlQuery; bool result = false; try ...

How to remove HTML tags from string in C#

I will show you three different methods to remove HTML tags from string in C#:1. By using Regex:public static string RemoveHTMLTags(string html) { return Regex.Replace(html, "<.*?>", string.Empty); }2. By using Compiled Regex for better performance:static Regex htmlRegex = new Regex("<.*?>", RegexOptions.Compiled); public static string RemoveHTMLTagsCompiled(string html) { return htmlRegex.Replace(html, string.Empty); }3. By...

Visual Studio 2005/2008 on Vista Internet Explorer cannot display the webpage

I faced a strange problem with Visual Studio 2005 and Visual Studio 2008 which is I have several ASP.NET Projects some of them using .NET 2.0 or Visual Studio 2005 and the others are using .NET 3.5 or Visual Studio 2008.The problem was when I try to run the Web...

Captcha image in C#.NET

What Captcha stand for?Completely Automated Public Turing test to tell Computers and Humans Apart. The Captcha technology help you to make sure your site is reasonably secure against automated attacks.Write the following code in a class named Captcha:public class Captcha { //make the captcha image for text public Bitmap MakeCaptchaImage(string txt,...

String functions StartsWith and EndsWith are case-sensitive in .NET

Did you know that String functions StartsWith and EndsWith are case-sensitive even in VB.NET?You will need to make sure you are looking for the correct string, since 'abc' with case-sensitivity is different than 'ABC'. So, if your function is looking for 'abc', you must make sure that you make adjustments...