Page post view or post views hit counter to count how many times any post or article on blogspot blog has been read.
Several times bloggers like to count how many times any post or articles on blog has been read.
But blogger doesn't provide any way for counting page views or any post hit counter widget
I've written a hit counter script for blogspot bloggers to count page / post views or hits and sharing it with everyone who needs it
to put page views counter in all posts of your blog , follow these steps
1. Login to Blogspot -> Dashboard -> Layout -> Edit HTML
2. click on expend widget Templates
3. find below mentioned line of code
Now paste below mentioned code above this line
<div id='hit-counter'>
<a href='http://csharpdotnetfreak.blogspot.com' rel='follow'>
<script src='http://www.amitjain.co.in/pageview.php' type='text/javascript'/> </a>
</div></b:if>
4. Save your template
For this Go to Layout > Click on Add a Gadget
Select HTML/Javascript
Now copy and paste below mentioned code in the box
Click on Save.
Test the post views counter, leave me a comment if you like it or having any problems in installing it
Have fun
Saturday, February 28, 2009
blogger page views post view hit counter to count views of post/page
Friday, February 20, 2009
yahoo messenger invisible detector Detect Yahoo messenger invisible friends
you want to find whether Your buddy is online in invisible mode on yahoo or not,
than just go to any of site mentioned below.
Put yahoo ID in search box
Click on search to find the invisible status of your friend
Continue reading this article
Thursday, February 19, 2009
C#.NET articles - creating online examination system in asp.net using master page and sql server
In this example i'm going to describe how to create online examination system using C# and ASP.NET with sql express as database
................
Related Posts:
LinkButton in GridView and QueryString Parameters to pass/transfer variable and data-ASP.NET Articles
The backup set holds a backup of a database other than the existing database-Sql Server Error 3154
ASP.NET Bypass forms authentication or Skip Authorization for selected pages
Tuesday, February 17, 2009
Blogger - Add dotnetshoutout button to all posts autometically
You want to add dotnetshoutout button to all posts of your blogspot/ blogger blog.
Than u need to write this code in your html section of blog
First of all go to layout > edit html >
Check the check box of expend widget templates
now look for this line of code
Continue reading this article
Monday, February 16, 2009
Failed to access IIS metabase ASP.NET
If You are getting "Failed to access IIS metabase" error while browsing asp.net site or aspx page in IIS server then you may have installed IIS Server after installing the .NET framework.
If that's the case, try running to repair your ASP.NET installation and set up all of the appropriate ISAPI extension mappings.
Open visual studio command prompt and type this command
aspnet_regiis -ga
if this doesn'twork than use this command
aspnet_regiis -i
alternatively you can copy and paste this command into windows command prompt
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
this will fix your problem
Other Posts:
Trace track Mobile Phone number location and operator in India
Import/Export Excel Data into Sql Server using SqlBulkCopy-ASP.NET
Delete multiple rows records in Gridview with checkbox and confirmation in ASP.NET
Saturday, February 14, 2009
C# Forms Authentication using ticket and managing user roles in asp.net
In this article i am going to describe how to implement Forms authentication using tickets and managing roles based access in ASP.NET using C#
For implementing forms authentication without using formsauthentication ticket, read my previous article - Forms Authentication with C# and managing folder lavel access with multiple web.config files
Configuring web.config file in application root
<forms defaultUrl="Default.aspx" loginUrl="~/Login.aspx"
slidingExpiration="true" timeout="20"></forms>
</authentication>
Defining roles and accessibility in root web.config
<system.web>
<authorization>
<allow roles="admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
Defining roles settings for folders and aspx within those folders in web.config file in those folders
<authorization>
<allow roles="user"/>
<deny users="*"/>
</authorization>
</system.web>
settings for any logged in member
<authorization>
<deny users="?"/>
</authorization>
Now after creating Login page we need to authenticate user
{
string userName = Login1.UserName;
string password = Login1.Password;
bool rememberUserName = Login1.RememberMeSet;
//Fetch User login information fromthe xml file into Dataset
string xmlFilePath = Server.MapPath("~/App_Data/LoginInfo.xml");
DataSet objDs = new DataSet();
objDs.ReadXml(xmlFilePath);
DataRow[] dRow = objDs.Tables[0].Select("UserName = '" + userName + "' and Password = '" + password + "'");
if (dRow.Length > 0)
{
//Fetch the role
string roles = dRow[0]["Roles"].ToString();
//Create Form Authentication ticket
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(20), rememberUserName, roles, FormsAuthentication.FormsCookiePath);
// In the above parameters 1 is ticket version, username is the username associated with this ticket
//time when ticket was issued , time when ticket will expire, remember username is user has chekced it
//roles associted with the user, and path of cookie if any
//For security reasons we may hash the cookies
string hashCookies = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies);
// add the cookie to user browser
Response.Cookies.Add(cookie);
// get the requested page
string returnUrl = Request.QueryString["ReturnUrl"];
if (returnUrl == null)
returnUrl = "~/Default.aspx";
Response.Redirect(returnUrl);
}
Now to retrieve the authentication and roles information on every request we need to write this code in Global.asax file
{
// look if any security information exists for this request
if (HttpContext.Current.User != null)
{
// see if this user is authenticated, any authenticated cookie (ticket) exists for this user
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
// see if the authentication is done using FormsAuthentication
if (HttpContext.Current.User.Identity is FormsIdentity)
{
// Get the roles stored for this request from the ticket
// get the identity of the user
FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity;
//Get the form authentication ticket of the user
FormsAuthenticationTicket ticket = identity.Ticket;
//Get the roles stored as UserData into ticket
string[] roles = ticket.UserData.Split(',');
//Create general prrincipal and assign it to current request
HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(identity, roles);
}
}
}
}
To check whether user in in the role or not we need to write this code in every page which provide access on role basis
{
if (HttpContext.Current.User.IsInRole("admin"))
{
lblMessage.Text = "Welcome Administrator";
}
}
Download sample code 
Related Articles :
1. Forms Authentication with C# and managing
folder lavel access with multiple web.config files
2. User validation across pages using session
after login in ASP.NET using C sharp
3. Detecting Session Timeout
and Redirect to Login Page in ASP.NET
Sunday, February 8, 2009
Ajax Cascading DropDownList With Database Example in GridView
There are several cases when you have two or three dropdowns in gridview and want second one (and third one) to be populated based on selection of first and second dropdownlist.
In this example i've implemented Ajax cascading drop down list in EditItemTemaplete of GridView for updation of records in grid by fetching data from database to populate dropdowns,I've also implemented ajax auto complete extender textbox in it to edit name field
Make sure you have created ajax enabled website and installed ajax toolkit and ajax web extensions properly
In this example gridview displays Name, City, and Country on page load,
And City and Country field turns into cascading dropdown list when user clicks on Edit link

Ajax cascading dropdown extender uses webservice to fetch data from database and populate dropdowns, city dropdown is populated based on country selected in country dropdown
Important points to remember
1. Put AjaxControlToolkit.dll in bin folder of your application.
2. Set EventValidation to false in page directive of your aspx page
<%@ Page Language="C#" EnableEventValidation="false"
AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
in order for the values to be submitted, EventValidation needs to be disabled for the page. EventValidation ensures that the values in each control match the values that were present when the page was rendered, but since these drop downs are populating on the client side, this is never true.
3. If you are getting Error method 500 or 12031 than read this to resolve this error
4. Webservice must have the webmethod with following signature and exact parameters
[WebMethod]
public CascadingDropDownNameValue[] GetColorsForModel(
string knownCategoryValues,
string category)
You can change the method name but return type must be CascadingDropDownNameValue[] with knownCategoryValues,category as parameters
First of all add a new webservice and name it CascadingDropDown.asmx
In code behind of this asmx file write following code
Add these namespaces
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using AjaxControlToolkit;
using System.Collections.Specialized;
/// <summary>
/// Summary description for CascadingDropDown
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class CascadingDropDown : System.Web.Services.WebService
{
//Create global Connection string
string strConnection = ConfigurationManager.ConnectionStrings
["dbConnectionString"].ConnectionString;
public CascadingDropDown () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
/// <summary>
/// WebMethod to populate country Dropdown
/// </summary>
/// <param name="knownCategoryValues"></param>
/// <param name="category"></param>
/// <returns>countrynames</returns>
[WebMethod]
public CascadingDropDownNameValue[] GetCountries
(string knownCategoryValues, string category)
{
//Create sql connection and sql command
SqlConnection con = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "Select * from Country";
//Create dataadapter and fill the dataset
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
DataSet objDs = new DataSet();
dAdapter.Fill(objDs);
con.Close();
//create list and add items in it
//by looping through dataset table
List<CascadingDropDownNameValue> countryNames
= new List<CascadingDropDownNameValue>();
foreach (DataRow dRow in objDs.Tables[0].Rows)
{
string countryID = dRow["CountryID"].ToString();
string countryName = dRow["CountryName"].ToString();
countryNames.Add(new CascadingDropDownNameValue
(countryName, countryID));
}
return countryNames.ToArray();
}
[WebMethod]
public CascadingDropDownNameValue[] GetCities
(string knownCategoryValues, string category)
{
int countryID;
//this stringdictionary contains has table with key value
//pair of cooountry and countryID
StringDictionary countryValues =
AjaxControlToolkit.CascadingDropDown.
ParseKnownCategoryValuesString(knownCategoryValues);
countryID = Convert.ToInt32(countryValues["Country"]);
SqlConnection con = new SqlConnection(strConnection);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.AddWithValue("@CountryID", countryID);
cmd.CommandText =
"Select * from City where CountryID = @CountryID";
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
DataSet objDs = new DataSet();
dAdapter.Fill(objDs);
con.Close();
List<CascadingDropDownNameValue> cityNames =
new List<CascadingDropDownNameValue>();
foreach (DataRow dRow in objDs.Tables[0].Rows)
{
string cityID = dRow["CityID"].ToString();
string cityName = dRow["CityName"].ToString();
cityNames.Add(new CascadingDropDownNameValue
(cityName, cityID));
}
return cityNames.ToArray();
}
}
Now in html source of aspx page I've put two dropdowns in EditItemTemaplate of gridview
<EditItemTemplate>
<asp:DropDownList ID="ddlCountry" runat="server">
</asp:DropDownList><br />
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1"
runat="server"
Category="Country"
TargetControlID="ddlCountry"
PromptText="-Select Country-"
LoadingText="Loading Countries.."
ServicePath="CascadingDropDown.asmx"
ServiceMethod="GetCountries">
</ajaxToolkit:CascadingDropDown>
</EditItemTemplate>
Here TargetControlID is id of dropdown on which cascading dropdown is to be implemented ,Service path is path to webservice and ServiceMethod is method to fetch the data from databse and populate dropdown
You also need to add reference to webservive in script manager
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="CascadingDropDown.asmx" />
</Services>
</asp:ScriptManager>
The complete html source is like this
<%@ Page Language="C#" EnableEventValidation="false"
AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="AutoComplete.asmx" />
<asp:ServiceReference Path="CascadingDropDown.asmx" />
</Services>
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
OnRowUpdating="GridView1_RowUpdating">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="ID" SortExpression="ID">
<ItemTemplate>
<asp:Label ID="lblID" runat="server"
Text='<%#Eval("ID") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblID" runat="server"
Text='<%#Bind("ID") %>'>
</asp:Label>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name"
SortExpression="Name">
<ItemTemplate>
<asp:Label ID = "lblName" runat="server"
Text='<%#Eval("Name") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server"
Text='<%#Bind("Name") %>' >
</asp:TextBox>
<ajaxToolkit:AutoCompleteExtender
runat="server"
ID="autoComplete1"
TargetControlID="txtName"
ServicePath="AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="10"
EnableCaching="true"
CompletionSetCount="12" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country"
SortExpression="Country">
<ItemTemplate>
<asp:Label ID="lblCountry" runat="server"
Text='<%#Eval("Country") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCountry" runat="server">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown
ID="CascadingDropDown1"
runat="server"
Category="Country"
TargetControlID="ddlCountry"
PromptText="-Select Country-"
LoadingText="Loading Countries.."
ServicePath="CascadingDropDown.asmx"
ServiceMethod="GetCountries">
</ajaxToolkit:CascadingDropDown>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City"
SortExpression="City">
<ItemTemplate>
<asp:Label ID="lblCity" runat="server"
Text='<%#Eval("City") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCity" runat="server"
OnSelectedIndexChanged="ddlCity_SelectedIndexChanged">
</asp:DropDownList><br />
<ajaxToolkit:CascadingDropDown
ID="CascadingDropDown2"
runat="server"
Category="City"
TargetControlID="ddlCity"
ParentControlID="ddlCountry"
PromptText="-Select City-"
LoadingText="Loading Cities.."
ServicePath="CascadingDropDown.asmx"
ServiceMethod="GetCities">
</ajaxToolkit:CascadingDropDown>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:dbConnectionString %>"
SelectCommand="SELECT [ID], [Name], [City],[Country]
FROM [Location]"
UpdateCommand="Update Location set [Name] = @Name,
[City] = @City,[Country] = @Country
where ID = @ID">
<UpdateParameters>
<asp:Parameter Name="Name" />
<asp:Parameter Name="ID" />
<asp:Parameter Name="Country"/>
<asp:Parameter Name="City"/>
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
Finally write this code in code behind of aspx page to update record
protected void GridView1_RowUpdating
(object sender, GridViewUpdateEventArgs e)
{
//Find dropdown to get selected Item text
DropDownList ddlGridCountry = (DropDownList)
GridView1.Rows[e.RowIndex].FindControl("ddlCountry");
string strCountry =
ddlGridCountry.SelectedItem.Text.ToString();
DropDownList ddlGridCity = (DropDownList)
GridView1.Rows[e.RowIndex].FindControl("ddlCity");
string strCity =
ddlGridCity.SelectedItem.Text.ToString();
SqlDataSource1.UpdateParameters.Clear();
SqlDataSource1.UpdateParameters.Add
("Country", strCountry);
SqlDataSource1.UpdateParameters.Add("City", strCity);
}
Hope this helps
I wrote similar article in case you don't use ajax , than u can go through this
1. C#.NET Articles -Cascading DropDownList Populate dropdown based on selection of other dropdown in ASP.NET
2. Populating dropdown based on the selection of first drop down in DetailsView using FindControl and ItemTemplate
Download the sample code attached

Search
Categories
- AJAX
- ASP.NET
- Authentication
- Blogger Tricks
- BloggerTips
- C#
- Cookies
- Cross Page Posting
- Crystal Reports
- DataKeyNames
- DataList
- DetailsView
- DropDownList
- FindControl
- GridView
- IIS
- ItemTemplate
- iTextSharp
- JavaScript
- ObjectDataSource
- Progress Template
- QueryString
- Server.Transfer
- Session
- Sql Server
- Submit Form
- Update Panel
- VB.NET
- Visual studio
- Web Service
- Web.config
- Windows Froms
- WinForms
Blog Archive
-
▼
2009
-
►
July 2009
- Merge GridView Cells Or Columns in Row ASP.NET C# ...
- SubReports in Crystal Reports in ASP.NET
- Combine Multiple Records Comma Separated In One Co...
- Running Total In Gridview Footer in ASP.NET C# VB....
- Crystal Reports in Winforms Windows Forms with Par...
- Scrollable GridView with fixed headers in asp.net ...
- FileUpload Save Images in Database in ASP.NET C# V...
- Display Images In GridView From DataBase C# VB.NET...
- PageMethods is undefined ASP.NET AJAX
- Crystal reports in ASP.NET
-
►
May 2009
- Unable to debug The binding handle is invalid VS20...
- AutoNumber Column or Auto Number in GridView or Da...
- Ajax Autocomplete textbox add progress Image using...
- Add Dynamic Checkbox And Handle CheckedChanged Eve...
- Shopping cart in ASP.NET Creating Example with Dat...
- Insert Update Edit Delete record in GridView using...
- Edit Update Multiple Records/Rows In Gridview With...
-
►
April 2009
- Delete multiple rows records in Gridview with chec...
- Export Import Excel Data into Sql Server Using Sql...
- Find Track mobile phone number location in india
- Trace Mobile Number Location Operator in India
- ASP.NET Bypass forms authentication or Skip Author...
- The backup set holds a backup of a database other ...
- LinkButton in GridView and QueryString in ASP.NET ...
- Unable to attach binding handle invalid error in v...
- Method error 500 / 12031 in implementing ajax casc...
- Disable Browser Back Button Using Javascript ASP.N...
- Highlight GridView Row On MouseOver Using Javascri...
-
▼
February 2009
- blogger page views post view hit counter to count ...
- yahoo messenger invisible detector Detect Yahoo me...
- C#.NET articles - creating online examination syst...
- Blogger - Add dotnetshoutout button to all posts a...
- Failed to access IIS metabase ASP.NET
- C# Forms Authentication using ticket and managing ...
- Ajax Cascading DropDownList With Database Example ...
-
►
July 2009
Topics
- AJAX
- ASP.NET
- Authentication
- Blogger Tricks
- BloggerTips
- C#
- Cookies
- Cross Page Posting
- Crystal Reports
- DataKeyNames
- DataList
- DetailsView
- DropDownList
- FindControl
- GridView
- IIS
- ItemTemplate
- iTextSharp
- JavaScript
- ObjectDataSource
- Progress Template
- QueryString
- Server.Transfer
- Session
- Sql Server
- Submit Form
- Update Panel
- VB.NET
- Visual studio
- Web Service
- Web.config
- Windows Froms
- WinForms
About Me
- amiT jaiN
- Hi, I am amiT jaiN Software engineer working on C#.NET and ASP.NET technologies







