Archive for August, 2008

How to install Google Analytics in Wordpress

For those who do not want to mess with PHP code .
Here is an easy way to add Google Analytics in wordpress.
1. Download the plug in from http://yoast.com/wordpress/google-analytics/
2. copy it to your plug ins folder
3. If you already don’t have an account, create one free account at www.google.com/analytics
4. Add your website. After you add your [...]

How to access a control in the masterpage ?

Suppose you have a label control name lblMessage in your masterpage and you want to access the label control from one of your pages, you can do so using the following code

Ctype( Page.Master.FindControl(”lblMessage”),Label).Text = “Hello”

Insert flash file correcty in ASP.NET masterpage

Many people have problems inserting flash files in masterpages . The following code is the correct way of inserting flash file in a mastepage . It will work in all situations

<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase= “http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0” width=”663″ height=”105″ title=”Serious Reading….”>
<param name=”movie” value=’<%= Request.ApplicationPath + “main_anim.swf” %>’
<param name=”quality” value=”high” />
<embed src=’<%= Request.ApplicationPath + “main_anim.swf” %>’ pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”663″ [...]

Basic SEO tips

Here are a few basic tips for on page search engine optimisation that i try to implement in all my websites.
1. The page title gets top priority. It should be short. Only your main keywords should be in the title. Eliminated all unwanted words. Replace the word “and” with | so that you can save [...]

Format dates in a Gridview column

To format a gridview column to display dates properly , two properties needs to be changed, the DateFormatString property and the HTML encode property. After setting the DateFormatString the HTMLEncode property should be set to false. For Example :

<asp:BoundField DataField=”RegistrationDate” DataFormatString=”{0:MM/dd/yyyy}” HeaderText=”Date”
HtmlEncode=”False” SortExpression=”RegistrationDate” />

Enable or disable the delete link in the GridView according to the role of the logged in user

In some scenarios you may only want users of a particular role to delete records from the GridView. So you need a mechanism to disable/hide the delete link in the gridview based on roles. The code below will enable the delete link only for “Admin” roles and disable it for the rest.

Protected [...]

Using MySQL in ASP.NET

Most web hosts provide more mySQL databases than SQl Server 2005 database. To keep your hosting costs low , you might need to use MySQL in your projects.
To connect to MySQL database
First download the drivers here
Then copy MySql.Data .dll and MySql.Web.dll to your bin directory
The connection string is as follows

<add name=”ASPNETDBConnectionString” connectionString = “Server=localhost;User [...]

How do I reference a server control in javascript?

<%=ServerControlID.ClientID%>
Yes that’s all you need . For Example suppose you have a asp.net textbox server control whose ID is “Textbox1″ . In your javascript code to get the value of the control you will use something like this

var myValue= document.getElementById(’<%=TextBox1.ClientID%>’).value;

Embed google maps easily in your asp.net pages

I found a nice and simple control Artem Google Map control . Its free, very simple to use and instructions are clearly provided . Just download the control file and put it in your bin directory. Sign up for a new Google Map key and note down the key. Here is an example of [...]