2010 in review

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meterâ„¢ reads This blog is doing awesome!.

Crunchy numbers

Featured image

The average container ship can carry about 4,500 containers. This blog was viewed about 17,000 times in 2010. If each view were a shipping container, your blog would have filled about 4 fully loaded ships.

 

In 2010, there was 1 new post, growing the total archive of this blog to 34 posts.

The busiest day of the year was August 30th with 97 views. The most popular post that day was Username Regex Validation.

Where did they come from?

The top referring sites in 2010 were forums.asp.net, google.co.in, stackoverflow.com, google.com, and velocityreviews.com.

Some visitors came searching, mostly for mssql rename column, operator ‘+’ cannot be applied to operands of type ‘string’ and ‘method group’, username regex, ms sql rename column, and rename column mssql.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Username Regex Validation October 2008

2

Operator + cannot be applied to operands of type string and method group, C# error September 2008
4 comments

3

Rename a table Column in MS SQL September 2008

4

ASp.Net 2.0 GridView Delete Button Confirmation pop-up August 2008
3 comments

5

Rotate a Label Text August 2008
1 comment


this._form is null or not an object, JavaScript Error

I was getting below javascript error everytime i run my visual studio asp.net web pages:

this._form is null or not an object

Because of this error all my AJAX controls and page postback stopped working.

As the error clearly states that it is a JavaScript error so i started checking all my Javascript code.

Finally searching on the internet i found the cause and cure of this problem.

Cause:

If you are including javascript files in the page header like an empty tag , like below :

<script src=”aj.js” type=”text/javascript” />

Solution:

Here the closing of script tag is not correct, through its an empty tag but somehow it needs to be closed as a old fashioned way, like done below:

<script src=”aj.js” type=”text/javascript”></script>

Close the javascript tag properly and see the magic yourself.


Read Excel files using C-Sharp windows application

This article explains how to read excel files using c sharp in windows applications.

using System.Data.OleDb;

private void btnRead_Click(object sender, EventArgs e)
{
try
{
string connStr = connStr = “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” + Application.StartupPath + @”\Courier.xls;Extended Properties=ImportMixedTypes=Text;Excel 8.0;HDR=Yes;IMEX=1;”;

//You must use the $ after the object you reference in the spreadsheet
OleDbDataAdapter adap = new OleDbDataAdapter(“SELECT * FROM [Sheet1$]”, connStr);

DataSet ds = new DataSet();
adap.Fill(ds, “Courier”);
dataGridView1.DataSource = ds.Tables[“Courier”].DefaultView;

}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

Explanation of the above code:
Here I used OleDb to read the excel file. The excel file resides with exe file as Courier.xls.

Sheet1$ is the name of excel sheet.
Courier is the name of file so i am using the same name in filling the DataSet.

Now at last the data is filled into dataGridView.

Now if you are not able to read the integer value or any value other then text then
include the
Extended Properties=ImportMixedTypes=Text;Excel 8.0;HDR=Yes;IMEX=1 property in connection string.

The above code can also be used in a web application, for this you need to replace the Application.StartupPath with Server.MapPath

HaPpY CoDiNg………..


URL rewriting using Global.asax, Error: The resource cannot be found.

Today I implemented my first application having URL rewriting enabled.
The application is created in Asp.net, C# and MS Sql 2005.

The url rewriting logic was working on the my localhost but it didn’t worked on production server.

I was getting an error: The resource cannot be found. while accessing the newly created URL pages.

I searched on Google about this and read lot, but nothing worked.

Finally I re-published the website and again uploaded all the files to production server and now everything worked like magic. Here is the URL: http://theplayclan.com/blog

Somewhere I read to check the permissions on server’s IIS, this method is explained below:

1) Open IIS manager.
2) Right click on your website’s virtual directory, select Properties.
3) Now, click on Configuration (in front of execute permissions option).
4) In the new popped-up window a list comes up as Application Extensions.
5) select .aspx option and click on edit.
6) Make sure that the Verify That File Exists is unchecked. This option explicitly check for the existence of file.
7) Save the settings and try again.

Somewhere it was mention to remove the *.* and regular expression extension mappings from the IIS may also work. The procedure of this is mentioned above.


Traverse / Loop through all form controls in asp.net

This post explains that how to traverse (loop through) all form controls in asp.net page.

foreach (System.Web.UI.Control ctrl in this.form1.Controls)
{
//here your code
}

Further if you want to get the state or data or manipulate the control, use the below code:
Here I am checking that at least one DropDownList item is selected out of all DropDownLists in the current webform.

bool isSelected = false;

foreach (System.Web.UI.Control ctrl in this.form1.Controls)
{

if (ctrl.GetType() == typeof(System.Web.UI.WebControls.DropDownList))
{
DropDownList ddl = (DropDownList)ctrl;

if (ddl.SelectedItem.Text != "")
{
isSelected = true;
break;
}
}

}

if (isSelected == true)
{
Response.Write("selected");
}
else
{
Response.Write("none selected");
}


Access your Asp.Net application over LAN

This post explains how to access some Asp.Net Application residing on another machine on network.

First of all you computer must be in the same workgroup as of the target computer. Then enter the following URL in the internet browser:

http://192.168.1.84/myWebsiteTest/default.aspx
or
http://ajay/myWebsiteTest/default.aspx

Here instead of ajay/192.168.1.84 you have to enter either the IP Address or the name of the computer on which asp.net application resides.

Just hit the enter key and you will see the output.

Happy Programing……..


MyBase in VB.Net is equal to base in C#

The Mybase object of VB.Net is similar to the base in C#.

So while using C# use “base” instead of “MyBase”.

Happy Programing……