<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Manoranjan&#039;s Tech World</title>
	<atom:link href="http://msahoo.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://msahoo.wordpress.com</link>
	<description>Explore Your Knowledge...</description>
	<lastBuildDate>Wed, 05 Oct 2011 23:09:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='msahoo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Manoranjan&#039;s Tech World</title>
		<link>http://msahoo.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://msahoo.wordpress.com/osd.xml" title="Manoranjan&#039;s Tech World" />
	<atom:link rel='hub' href='http://msahoo.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Speed up your ASP.Net website by using HTTP compression</title>
		<link>http://msahoo.wordpress.com/2011/07/22/speed-up-your-asp-net-website-by-using-http-compression/</link>
		<comments>http://msahoo.wordpress.com/2011/07/22/speed-up-your-asp-net-website-by-using-http-compression/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 05:22:18 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=223</guid>
		<description><![CDATA[Page loading speed is very important thing for any website. If your website takes too much time to load webpage then it may affects your user. So, you need to speed up your page loading. There are several techniques available to speed up the site. HTTP compression is one of the technique. There are two [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=223&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Page loading speed is very important thing for any website. If your website takes too much time to load webpage then it may affects your user. So, you need to speed up your page loading. There are several techniques available to speed up the site. HTTP compression is one of the technique. There are two types of compression available in .Net. i.e. :</p>
<ul>
<li>GZip</li>
<li>deflate</li>
</ul>
<p>By using above two compression technique you can speed up your asp.net website.</p>
<p>Compression can be performed in two stages. i.e. IIS level or Web Site level. If you enable in IIS level then it will reflect to all website hosted on that IIS. if you want to setup IIS level compression then <a title="IIS Level compression" href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/502ef631-3695-4616-b268-cbe7cf1351ce.mspx?mfr=true" target="_blank">click here</a>. If you want to do in a single website then you can do by little changes in code. In this article i am going to explain in detail about page level or website level compression.</p>
<h3>How to do HTTP Compression?</h3>
<p>To accomplish this, We need to compress the response output. It can be easily done by DeflateStream or GzipStream classes.  These two classes available in <span style="color:#3366ff;"><code>System.IO.Compression</code></span>  namespace. Between these two deflate is the more fast than Gzip. Because Gzip contains more header info than deflate. To use HTTP compression in our ASP.NET website without editing each and every single page, we will use ASP.NET web application&#8217;s life cycle events in <span style="color:#3366ff;">Global.asax</span> file.</p>
<p>A Global.asax file is placed in your root folder. There are several methods available in Global.asax file to handle ASP.Net life cycle events. We will handle <span style="color:#3366ff;">PreRequestHandlerExecute</span> event to insert our code in this method. This event occurs just before ASP.NET starts executing an event handler.</p>
<p>To do the HTTP  compression follow below steps :</p>
<p>1.  create Global.asax file in the root directory(if there is no Global.asax file).</p>
<p>2. Then make some changes as per the below code.</p>
<pre>&lt;%@ Application Language="C#" %&gt;
&lt;%@ Import Namespace="System.IO" %&gt;
&lt;%@ Import Namespace="System.IO.Compression" %&gt;

&lt;script runat="server"&gt;

    void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        HttpApplication app = sender as HttpApplication;
        string acceptEncoding = app.Request.Headers["Accept-Encoding"];
        Stream prevUncompressedStream = app.Response.Filter;

        if (!(app.Context.CurrentHandler is Page ||
            app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler") ||
            app.Request["HTTP_X_MICROSOFTAJAX"] != null)
            return;

        if (acceptEncoding == null || acceptEncoding.Length == 0)
            return;

        acceptEncoding = acceptEncoding.ToLower();

        if (acceptEncoding.Contains("deflate") || acceptEncoding == "*")
        {
            // defalte
            app.Response.Filter = new DeflateStream(prevUncompressedStream,
                CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "deflate");
        }
        else if (acceptEncoding.Contains("gzip"))
        {
            // gzip
            app.Response.Filter = new GZipStream(prevUncompressedStream,
                CompressionMode.Compress);
            app.Response.AppendHeader("Content-Encoding", "gzip");
        }
    }
    void Application_Start(object sender, EventArgs e)
    {
        // Code that runs on application startup

    }

    void Application_End(object sender, EventArgs e)
    {
        //  Code that runs on application shutdown

    }

    void Application_Error(object sender, EventArgs e)
    {
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.

    }

&lt;/script&gt;</pre>
<p>The above code will enable HTTP compression in your ASP.NET website.</p>
<p>The first thing we do is to tell the ASP.NET compiler that we are using C# language. It means all the below codes are in C# language.</p>
<pre>&lt;%@ Application Language="C#" %&gt;</pre>
<p>As i said above the <code></code><code></code><code>DeflateStream</code> and <code>GZipStream</code> classes are available in the <code>System.IO.Compression</code> namespace. So we need to import this namespace.</p>
<pre>&lt;%@ Import Namespace="System.IO" %&gt;
&lt;%@ Import Namespace="System.IO.Compression" %&gt;</pre>
<p>Next, we need to declare the method which will handle the <code>PreRequestHandlerExecute</code> life cycle event.</p>
<pre>void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
	...
}</pre>
<p>Then in this method, We need to confirm that the requested ASP.NET resource is either a valid ASP.NET page or a Web Service. If it is not, then we just return and do nothing. we also check for <span style="color:#3366ff;">&#8220;HTTP_X_MICROSOFTAJAX&#8221;</span> item in the HttpRequest collection. This item is present if we are using AJAX in our web site.  because if we use AJAX and then compress the HTTP then it will through an exception.</p>
<p><strong>app.Response.Filter</strong> exposes a Stream which we override with a GZipStream object or deflate object, this will cause the raw text response to get compressed, then we need to tell the browser that this response is compressed. So we need to add this to header by  <strong>app.Response.AppendHeader</strong>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/223/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/223/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/223/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=223&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/07/22/speed-up-your-asp-net-website-by-using-http-compression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>Temporary Tables in SQL Server</title>
		<link>http://msahoo.wordpress.com/2011/07/20/temporary-tables-in-sql-server/</link>
		<comments>http://msahoo.wordpress.com/2011/07/20/temporary-tables-in-sql-server/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 08:21:56 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[temporary table]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=218</guid>
		<description><![CDATA[Introduction Temporary table is very useful tool in SQL Server for developer. It provided short term use of data. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=218&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Temporary table is very useful tool in SQL Server for developer. It provided short term use of data. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside <span style="color:#800000;">tempdb</span> database. There are two types of temporary table in SQL Server:<br />
1. Local<br />
2. Global</p>
<p><strong>Local :</strong> Local temporary tables are only available to the current connection to the database for the current user. These are dropped automatically when the connection is closed.</p>
<p><strong>Global :</strong> Global temporary tables are available to all connections that created and exist to that database. These are dropped when the last connection using it is closed.</p>
<p>Both types of temporary tables are created in the system database <span style="color:#800000;">tempdb</span>.</p>
<h3>How to create Temporary Tables?</h3>
<p>Temporary tables can be created like any table in SQL Server with a CREATE TABLE or SELECT..INTO statement.<br />
To make the table as local temporary table, attach (#) as prefix with the name of the table.<br />
To make the table as global temporary table, attach (##) as prefix with the name of the table.</p>
<p>Create Local Temporary Table using Create Table statement.<br />
<strong>Code :</strong></p>
<pre>
CREATE TABLE #TempTable1
(
tempfield1 INT,
tempfield2 VARCHAR(50)
)
</pre>
<p>Create Local Temporary Table using SELECT &#8230; INTO statement.<br />
<strong>Code :</strong></p>
<pre>
SELECT
tempfield1 as id,
tempfield2 as Name
INTO #TempTable1 FROM ActualTable1
</pre>
<p>Above sample codes will create a local temporary table named #TempTable1 with two fields with name tempfield1 and tempfield2.</p>
<p>Create Global Temporary Table using Create Table statement.<br />
<strong>Code :</strong></p>
<pre>
--replace # to ##
CREATE TABLE ##TempTable1
(
tempfield1 INT,
tempfield2 VARCHAR(50)
)
</pre>
<p>Create Global Temporary Table using SELECT &#8230; INTO statement.<br />
<strong>Code :</strong></p>
<pre>
SELECT
tempfield1 as id,
tempfield2 as Name
INTO ##TempTable1 FROM ActualTable1
</pre>
<p>How to check if Temporary table exist?</p>
<p>use below stored procedure for checking local temp table:</p>
<pre>
IF OBJECT_ID('tempdb..#TempTable1') IS NOT NULL
BEGIN
PRINT '#TempTable1 exists'
END
ELSE
BEGIN
PRINT '#TempTable1 does not exist'
END
</pre>
<p>use below code for checking global TempTable1 table :</p>
<pre>
IF OBJECT_ID('tempdb..##TempTable1') IS NOT NULL
BEGIN
PRINT '##TempTable1 exists'
END
ELSE
BEGIN
PRINT '##TempTable1 does not exist'
END
</pre>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/sql/'>sql</a>, <a href='http://msahoo.wordpress.com/tag/sql-server-2/'>sql server</a>, <a href='http://msahoo.wordpress.com/tag/temporary-table/'>temporary table</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/218/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/218/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/218/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=218&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/07/20/temporary-tables-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>Displaying image in a gridview</title>
		<link>http://msahoo.wordpress.com/2011/07/19/displaying-image-in-a-gridview/</link>
		<comments>http://msahoo.wordpress.com/2011/07/19/displaying-image-in-a-gridview/#comments</comments>
		<pubDate>Tue, 19 Jul 2011 05:47:00 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[c#.net gridview]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=212</guid>
		<description><![CDATA[Can not display images in gridview? Many times I have seen people getting problem to show image in a gridview. This problem arises normally due to wrong image URL. This is because web server was not able to find the image. Consider an example where, in my root directory I have a folder name images [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=212&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Can not display images in gridview?</p>
<p>Many times I have seen people getting problem to show image in a gridview. This problem arises normally due to wrong image URL. This is because web server was not able to find the image.</p>
<p>Consider an example where, in my root directory I have a folder name images and my root directory also presents in a physical media(HardDrive). and i saved the image file in database with physical path(ex : c:\\mywebsite\images\a.jpg).</p>
<p>Then i tried to fetch the path from database and showing in gridview. At this time it will give the physical path to the image control. but in case of website, all data present in a virtual directory. So we need to give the virtual path to the image. Because when we open the page on browser it will search the content of images from virtual path.</p>
<p>When you save the path into database, just save the virtual path of the image. To get virtual path follow below code :</p>
<p><span style="color:#0000ff;">string</span> filename=<span style="color:#3366ff;">Server</span>.MapPath(<span style="color:#800000;">&#8220;~/images/a.jpg&#8221;</span>);</p>
<p>Then you can save filename into database.</p>
<p>To show the image into gridview design gridview like below code :</p>
<pre>&lt;asp:GridView runat="server" ID="gv_Products" AutoGenerateColumns="false"  &gt;

&lt;Columns&gt;
&lt;asp:BoundField DataField="ProductNm" HeaderText="Product Name" ItemStyle-Height= "100px" ItemStyle-Width = "200px" /&gt;
&lt;asp:BoundField DataField="Price" HeaderText="Price" ItemStyle-Height= "100px" ItemStyle-Width = "200px"/&gt;
&lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
               &lt;img src='&lt;%# Eval("ProductImgPath") %&gt;' /&gt;
       &lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;
&lt;/Columns&gt;
&lt;/asp:GridView&gt;</pre>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a>, <a href='http://msahoo.wordpress.com/tag/c-net-gridview/'>c#.net gridview</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/212/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/212/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/212/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=212&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/07/19/displaying-image-in-a-gridview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>Create simple guest book in ASP.Net and C#.Net</title>
		<link>http://msahoo.wordpress.com/2011/05/23/create-simple-guest-book-in-asp-net-and-c-net/</link>
		<comments>http://msahoo.wordpress.com/2011/05/23/create-simple-guest-book-in-asp-net-and-c-net/#comments</comments>
		<pubDate>Mon, 23 May 2011 01:47:50 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[create guest book]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=207</guid>
		<description><![CDATA[Sometimes we need to put guest book in our website. Suppose we don&#8217;t have any database to save the data. At that time, what can we do to save the data? We can use simple text file to save the data. check below code : in page.ASPX page : &#60;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=207&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes we need to put guest book in our website. Suppose we don&#8217;t have any database to save the data. At that time, what can we do to save the data?</p>
<p>We can use simple text file to save the data.</p>
<p>check below code :</p>
<p>in page.ASPX page :</p>
<pre>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;GuestBook&lt;/title&gt;
    &lt;style &gt;
    hr
    {
        height:1px;
        background:#446791;
    }
    .time
    {
        font-size :11px;
        font-family :Arial;
    }
    .name
    {
        font-family :Arial ;
        font-size :11px;
        font-weight :bold;
    }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
        &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
        &lt;asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick"&gt;
        &lt;/asp:Timer&gt;
        &lt;asp:UpdatePanel ID="UpdatePanel1" UpdateMode ="Conditional"  runat="server"&gt;
        &lt;Triggers &gt;
           &lt;asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /&gt;
        &lt;/Triggers&gt;
        &lt;ContentTemplate &gt;
            &lt;asp:Label ID="Label1" runat="server" Text=""&gt;&lt;/asp:Label&gt;&lt;br /&gt;
            &lt;div style ="width :815px; height :500px; overflow :auto "&gt;
                &lt;asp:Label ID="lblMsg" style="padding:5px" runat="server" Text="" Width ="800px" BorderColor ="Teal" BorderWidth ="1px" BorderStyle ="Solid" BackColor ="AliceBlue"  &gt;&lt;/asp:Label&gt;
            &lt;/div&gt;
        &lt;/ContentTemplate&gt;
        &lt;/asp:UpdatePanel&gt;
        &lt;asp:UpdatePanel ID="UpdatePanel2" UpdateMode ="Conditional" runat ="server" &gt;
        &lt;Triggers &gt;
        &lt;asp:PostBackTrigger ControlID ="btnSend" /&gt;
        &lt;/Triggers&gt;
        &lt;ContentTemplate &gt;
        &lt;br /&gt;&lt;br /&gt;
            &lt;asp:TextBox ID="txtName" runat="server"&gt;&lt;/asp:TextBox&gt;
            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate ="txtName" ErrorMessage="Enter Your Name"&gt;&lt;/asp:RequiredFieldValidator&gt;
            &lt;br /&gt;
            &lt;asp:TextBox ID="txtMsg" TextMode ="MultiLine" Width="500px" Height="60px" runat="server" &gt;&lt;/asp:TextBox&gt;
            &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate ="txtMsg" ErrorMessage="Enter Message"&gt;&lt;/asp:RequiredFieldValidator&gt;
            &lt;asp:Button ID="btnSend" runat="server" Text="Submit" Font-Bold ="true"  onclick="btnSend_Click" /&gt;
        &lt;/ContentTemplate&gt;
        &lt;/asp:UpdatePanel&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Now download for full source code and cs code file :</p>
<p><span class="Apple-style-span" style="color:#008000;"><strong>Download Full Working Source Code from below links :</strong></span></p>
<p><span style="color:#3366ff;"><strong>1. http://uploading.com/files/1832m6ee/GuestBook.zip/</strong></span></p>
<p>Thank You.</p>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a>, <a href='http://msahoo.wordpress.com/tag/c-net/'>C#.Net</a>, <a href='http://msahoo.wordpress.com/tag/create-guest-book/'>create guest book</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=207&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/05/23/create-simple-guest-book-in-asp-net-and-c-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>How to access the server control of content page inside the javascript?</title>
		<link>http://msahoo.wordpress.com/2011/04/23/how-to-access-the-server-control-of-content-page-inside-the-javascript/</link>
		<comments>http://msahoo.wordpress.com/2011/04/23/how-to-access-the-server-control-of-content-page-inside-the-javascript/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 03:44:22 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#.Net]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=200</guid>
		<description><![CDATA[Hello, Sometime i used to create websites using Master Page. Some server controls are added into content page. For some cases i need to use to change the value of those control at client side. So usually write javascript code. For example : Suppose i want to add two number and show the result. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=200&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
Sometime i used to create websites using Master Page. Some server controls are added into content page. For some cases i need to use to change the value of those control at client side. So usually write javascript code.</p>
<p>For example : Suppose i want to add two number and show the result. I want to perform addition in client side and show the result on content page&#8217;s Label control.</p>
<p>for this first i wrote the below code :</p>
<pre class="brush:js">function addNumber(val1,val2)
{
var result=val1+val2;
document.getElementById('Label1').innerHTML = result;
}
</pre>
<p>But the above code gives javascript error. i.e : unrecognised id.<br />
Because the content page&#8217;s control id converted as per contentplace holder id.<br />
So i modified the code to below code.</p>
<pre class="brush:js">function addNumber(val1,val2)

{

var result=val1+val2;

document.getElementById('&lt;%=Label1.ClientID%&gt;').innerHTML = result;

}
</pre>
<p>The above code works fine.</p>
<p>so whenever you want to access the content page&#8217;s control at client side just put the clientID of that control not the control id only.</p>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a>, <a href='http://msahoo.wordpress.com/tag/c-net/'>C#.Net</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=200&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/04/23/how-to-access-the-server-control-of-content-page-inside-the-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>Create HitCounter using ASP.Net and C#.Net</title>
		<link>http://msahoo.wordpress.com/2011/04/23/create-hitcounter-using-asp-net-and-c-net/</link>
		<comments>http://msahoo.wordpress.com/2011/04/23/create-hitcounter-using-asp-net-and-c-net/#comments</comments>
		<pubDate>Sat, 23 Apr 2011 03:42:56 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[Create Hit Counter]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=197</guid>
		<description><![CDATA[Hello Friends, Some of our user writes to post the code for hit counter and i created a sample application. Here i posted the code and sample application. To do so follow the below steps : Step 1 : Open your project. then add one text file with name &#8220;hitcounter.txt&#8221;. Step 2 : Then open [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=197&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello Friends,<br />
Some of our user writes to post the code for hit counter and i created a sample application.<br />
Here i posted the code and sample application.</p>
<p>To do so follow the below steps :</p>
<h3><span style="color:#3366ff;">Step 1 :</span></h3>
<p>Open your project. then add one text file with name &#8220;hitcounter.txt&#8221;.</p>
<h3><span style="color:#3366ff;">Step 2 :</span></h3>
<p>Then open the page where you want to place the hit counter.</p>
<h3><span style="color:#3366ff;">Step 3 :</span></h3>
<p>Then Goto Page_Load event of that page. and put the below code.<br />
<span style="color:#ff6600;"><strong>Note :</strong></span> Here i used to put the code with Response.Write method. you can set the counter to a Label control. To show on Label Control use : <span style="color:#0000ff;">Label1.Text=gethitcounts();</span> instead of <span style="color:#0000ff;">Response.Write(gethitcounts());</span></p>
<h3><span style="color:#3366ff;">Code :</span></h3>
<pre class="brush:c#">using System.IO;
protected void Page_Load(object sender, EventArgs e)
{
    Application.Lock();
    Response.Write(gethitcounts()); //you can change here for label control
    Application.UnLock();
}
public string gethitcounts()
{
    string lastcount = "";
    try
    {
        StreamReader SR = File.OpenText(Server.MapPath("hitcounter.txt"));
        string getcount = null;
        while ((getcount = SR.ReadLine()) != null)
        {
            lastcount = lastcount + getcount;
        }
        SR.Close();
        long newcount = Convert.ToInt64(lastcount);
        newcount++;
        TextWriter TxtWtr = new StreamWriter(Server.MapPath("hitcounter.txt"));
        TxtWtr.WriteLine(Convert.ToString(newcount));
        TxtWtr.Close();
        SR = File.OpenText(Server.MapPath("hitcounter.txt"));
        getcount = null;
        lastcount = "";
        while ((getcount = SR.ReadLine()) != null)
        {
            lastcount = lastcount + getcount;
        }
        SR.Close();
    }
    catch (Exception ex)
    {
        TextWriter TxtWtr = new StreamWriter(Server.MapPath("hitcounter.txt"));
        TxtWtr.WriteLine(Convert.ToString("1"));
        TxtWtr.Close();
        lastcount = "1";
    }
    return lastcount;
}</pre>
<p><span style="color:#008000;"><strong><a href="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/HitCounter.zip">Download Sample Code</a></strong></span></p>
<p><strong>1. http://www.filesonic.com/file/1026929374/Hit_Counter.zip </strong></p>
<p><strong>2. http://www.fileserve.com/file/w7EcdZf </strong></p>
<p><strong>3. http://uploading.com/files/3ae87245/Hit_Counter.zip/</strong></p>
<p><strong>4. http://letitbit.net/download/47886.405cee85e9b5a71b90f8b92256c5/Hit_Counter.zip.html</strong></p>
<p>Thank You.</p>
<p>Regards,<br />
Manoranjan Sahoo</p>
<p>http://www.dotnetsquare.com</p>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a>, <a href='http://msahoo.wordpress.com/tag/c-net/'>C#.Net</a>, <a href='http://msahoo.wordpress.com/tag/create-hit-counter/'>Create Hit Counter</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=197&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2011/04/23/create-hitcounter-using-asp-net-and-c-net/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>Upload Files in ASP.NET at Production Web server</title>
		<link>http://msahoo.wordpress.com/2010/10/07/upload-files-in-asp-net-at-production-web-server/</link>
		<comments>http://msahoo.wordpress.com/2010/10/07/upload-files-in-asp-net-at-production-web-server/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 01:01:17 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[C#.Net]]></category>
		<category><![CDATA[File Upload]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=194</guid>
		<description><![CDATA[Most of the case, a developer created a code to upload the file and test it on his local machine. Program runs perfectly on local machine, but after publish that onto production server. He stuck in the file permission error as on the local machine he has the full permission whereas on the production server [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=194&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Most of the case, a developer created a code to upload the  file and test it on his local machine. Program runs perfectly on local  machine, but after publish that onto production server. He stuck in the  file permission error as on the local machine he has the full permission  whereas on the production server its not the case.</p>
<p>So i decided  to write this tutorial for the beginners which will demonstrate how to  upload a file onto webserver or production server.</p>
<h2><span style="color:#3366ff;">Step 1 :</span></h2>
<p>First we need to create a folder in Server and share it with ASP.NET  web server as described. Right click on folder, select Web sharing tab  and select the radio button <strong>&#8220;Share this folder&#8221;</strong>. One  window appear,  give it alias name which will be used in coding.</p>
<p><a href="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/WebShare-Folder.png"><img class="aligncenter size-full wp-image-210" title="WebShare-Folder" src="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/WebShare-Folder.png" alt="" width="471" height="510" /></a></p>
<h2><span style="color:#3366ff;">Step 2 :</span></h2>
<p>After this, open Run box and type <strong>&#8220;inetmgr&#8221;</strong>. you will see that  your web shared folder appears in the IIS.</p>
<p><a href="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/IIS.png"><img class="aligncenter size-full wp-image-211" title="IIS" src="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/IIS.png" alt="" width="274" height="476" /></a></p>
<h2><span style="color:#3366ff;">Step 3 :</span></h2>
<p>Right click on folders property. one window will opened like below.</p>
<h2><span style="color:#3366ff;">Step  4 :</span></h2>
<p>Select <strong>&#8220;Directory Security&#8221;</strong> tab then click on <strong>&#8220;Edit&#8221;</strong> button and then check <strong>&#8220;Anonymous access&#8221;</strong>. And because of this  setting any body can access or download that file.</p>
<p><a href="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/anonomouse-Access.png"><img class="aligncenter size-full wp-image-212" title="anonomouse-Access" src="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/anonomouse-Access.png" alt="" width="643" height="566" /></a></p>
<p><strong><em>Now we  are ready, to create a sample application which will demonstrate that  how to upload the file and use it.</em></strong></p>
<h2><span style="color:#3366ff;">Step 5 :</span></h2>
<p>Create ASP.NET project in Visual Studio. Create a webpage with  fileupload, hyperlink and button control.</p>
<pre class="xml">&lt;form runat="server"&gt;
&lt;asp:FileUpload runat="server" /&gt;&lt;br /&gt;
&lt;asp:HyperLink runat="server" Visible="false" Target="_blank"&gt;&lt;/asp:HyperLink&gt;&lt;br /&gt;
&lt;asp:Button Text="Upload" runat="server" /&gt;
&lt;/form&gt;
</pre>
<h2><span style="color:#3366ff;">Step 6 :</span></h2>
<p>In <strong>web.config</strong> add two keys.  One for  actual folder location in which we are going to upload the files and  other its alias name. we can also hard code that, but its good practice  to make it configurable at any time because in near future we may want  to change the location.</p>
<pre class="xml">&lt;appSettings&gt;
&lt;add key="DemoAttachment" value="D:\Share\DemoShare\"&gt;&lt;/add&gt;
&lt;add key="DemoAttachmentVirtualPath" value="http://localhost/DemoShare/"&gt;&lt;/add&gt;
&lt;/appSettings&gt;</pre>
<p><em><strong>Note :</strong> In DemoAttachmentVirtualPath key, value should  like <strong>&#8220;http://machinename/&#8221; </strong>+ Alias folder name.</em></p>
<h2><span style="color:#3366ff;">Step 7 :</span></h2>
<p>On click event of button, write below code:</p>
<pre class="brush:c#">string strPath = ConfigurationManager.AppSettings["DemoAttachment"];
uploadFile.SaveAs(strPath + System.IO.Path.GetFileName(uploadFile.FileName));
hypLink.Visible = true;
string VirtualPath = ConfigurationManager.AppSettings["DemoAttachmentVirtualPath"];
hypLink.Text = System.IO.Path.GetFileName(uploadFile.FileName);
hypLink.NavigateUrl = VirtualPath + uploadFile.FileName;</pre>
<h3 style="text-align:center;"><span style="color:#ff6600;"><a href="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/38711-2330-FileUploadDemo.zip">FileUploadDemo</a></span></h3>
<p>This Post is provided by my friend Jitendra. Find his useful post <a href="http://blog.shivasoft.in">here</a></p>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a>, <a href='http://msahoo.wordpress.com/tag/c-net/'>C#.Net</a>, <a href='http://msahoo.wordpress.com/tag/file-upload/'>File Upload</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=194&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2010/10/07/upload-files-in-asp-net-at-production-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>

		<media:content url="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/WebShare-Folder.png" medium="image">
			<media:title type="html">WebShare-Folder</media:title>
		</media:content>

		<media:content url="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/IIS.png" medium="image">
			<media:title type="html">IIS</media:title>
		</media:content>

		<media:content url="http://blog.dotnetsquare.com/wp-content/uploads/2010/06/anonomouse-Access.png" medium="image">
			<media:title type="html">anonomouse-Access</media:title>
		</media:content>
	</item>
		<item>
		<title>Export GridView To Excel using C#.Net</title>
		<link>http://msahoo.wordpress.com/2010/05/17/export-gridview-to-excel-using-c-net/</link>
		<comments>http://msahoo.wordpress.com/2010/05/17/export-gridview-to-excel-using-c-net/#comments</comments>
		<pubDate>Mon, 17 May 2010 05:39:41 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=176</guid>
		<description><![CDATA[Here I provide the simple code for export gridview to excel in c#.net. Here i considered that, there is one gridview and two button.One button to fetch the data and show on gridview and other is to export that data into excel. To export follow the below steps. Step 1 : Create one .aspx file. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=176&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here I provide the simple code for export gridview to excel in c#.net. Here i considered that, there is one gridview and two button.One button to fetch the data and show on gridview and other is to export that data into excel. To export follow the below steps.</p>
<h3><strong><span style="color:#3366ff;">Step 1 :</span></strong></h3>
<p>Create one .aspx file. Add one gridview and two button to this.</p>
<h3><strong><span style="color:#3366ff;">Step2 :</span></strong></h3>
<p>Now Name one of those button as btnExportToExcel. then write the following code to the click event of that button. Make changes the sql query as per your need.</p>
<h3><span style="color:#3366ff;"><strong>Code</strong> : </span></h3>
<pre><span style="color:#000080;">protected void btnExportToExcel_Click(object sender, EventArgs e)
{
    try
    {
		string lblSQLQry="select * from  tablename where &lt;condition&gt;";
		string fileName="FileName";//you can also pass a unique file name here
        ExportToExcelwithDatareader1(lblSQLQry, fileName);
    }
    catch (SqlException ex){}
    catch (SystemException ex){}
}</span></pre>
<h3><span style="color:#3366ff;">Step3 :</span></h3>
<p>Below the above click event method write the following method.  Make changes the connection details as per your need.</p>
<h3><span style="color:#3366ff;">Code : </span></h3>
<pre><span style="color:#000080;">public void ExportToExcelwithDatareader1(string strqry, string strfileName)
{
    try
    {
        SqlDataReader dr = null;
        StringBuilder sb = new StringBuilder();
		SqlCommand cmdexreader = new  SqlCommand();
		SqlConnection sqlconn="Your SQL Server Connection String";
        sqlconn.Open();
        cmdexreader.CommandText = strqry;
        cmdexreader.CommandTimeout = 0;
        cmdexreader.Connection =sqlconn;
        dr = cmdexreader.ExecuteReader(CommandBehavior.CloseConnection);
		string headername="Report";
        sb.Append("&lt;TABLE border='1'&gt;&lt;Center&gt;&lt;thead style='font-size:16;font-family:Verdana;color:green'&gt;&lt;font color='green' size='5'&gt;&lt;b&gt;" + headername + "&lt;/font&gt;&lt;/thead&gt;&lt;/Center&gt;");
        for (int count = 1; count &lt; dr.FieldCount - 3; count++)
        {
            string thname = "";
            thname = dr.GetName(count).ToString();
            sb.Append("&lt;TH width='71' style='background-color:orange;position:fixed;color:White;font-family:Verdana;white-space: pre-wrap ;font-size:14'&gt;&lt;b&gt;" + thname + "&lt;/b&gt;&lt;/TH&gt;");
        }
        while (dr.Read())
        {
            sb.Append("&lt;TR&gt;");
            for (int col = 1; col &lt; dr.FieldCount - 3; col++)
            {
                sb.Append("&lt;TD align='Center'&gt;&lt;font color='black'&gt;" + dr.GetValue(col).ToString() + "&lt;/font&gt;&lt;/TD&gt;");
            }
            sb.Append("&lt;/TR&gt;");
        }
        dr.Dispose();
        sb.Append("&lt;/TABLE&gt;");
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=" + strfileName + ".xls");
        Response.Charset = "";
        Response.ContentType = "application/vnd.xls";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        stringWrite.WriteLine(sb.ToString());
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        Response.Write(stringWrite.ToString());
        Response.Flush();
        Response.End();
    }
    catch (Exception ex){}
}</span></pre>
<h3><span style="color:#3366ff;">Step 4 :</span></h3>
<p>That&#8217;s it. Now you can run the file to see the output.</p>
<p>Thank You.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=176&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2010/05/17/export-gridview-to-excel-using-c-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>How to get the result as 00 format for month or date of a datetime from SQL ?</title>
		<link>http://msahoo.wordpress.com/2010/05/12/how-to-get-the-result-as-00-format-for-month-or-date-of-a-date-from-sql/</link>
		<comments>http://msahoo.wordpress.com/2010/05/12/how-to-get-the-result-as-00-format-for-month-or-date-of-a-date-from-sql/#comments</comments>
		<pubDate>Wed, 12 May 2010 00:54:42 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=167</guid>
		<description><![CDATA[Hi, One day i need to fetch the month part of a date field of my sql database. i tried the following code to get the month part : select datepart(MONTH,[Date]) from tablename but it gives the result as : 1,2,3&#8230; But i need as 01,02,03&#8230;. so i change the sql syntax as below : [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=167&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
One day i need to fetch the month part of a date field of my sql database. i tried the following code to get the month part :</p>
<pre><span style="color:#0000ff;">select datepart(MONTH,[Date]) from tablename</span></pre>
<p>but it gives the result as :</p>
<p>1,2,3&#8230;</p>
<p>But i need as 01,02,03&#8230;.</p>
<p>so i change the sql syntax as below :</p>
<pre><span style="color:#0000ff;">SELECT RIGHT(REPLICATE('0', 2) + CAST(datepart(MONTH,[Date]) AS VARCHAR(2)), 2) FROM Tablename</span></pre>
<p><span style="color:#ff6600;">or</span> you can use simple :</p>
<pre><span style="color:#0000ff;">SELECT RIGHT('0' + convert(varchar(2),datepart(MONTH,[Date])), 2) FROM &lt;TableName&gt;</span></pre>
<p><span style="color:#0000ff;"><span style="color:#000000;">it gives me the correct result&#8230;</span></span></p>
<p><span style="color:#0000ff;"><span style="color:#000000;">Thank You.</span></span></p>
<p><span style="color:#0000ff;"><span style="color:#000000;"><br />
</span></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/167/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/167/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/167/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=167&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2010/05/12/how-to-get-the-result-as-00-format-for-month-or-date-of-a-date-from-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.Net Error: Response is not available in this context</title>
		<link>http://msahoo.wordpress.com/2010/03/16/asp-net-error-response-is-not-available-in-this-context/</link>
		<comments>http://msahoo.wordpress.com/2010/03/16/asp-net-error-response-is-not-available-in-this-context/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 02:07:44 +0000</pubDate>
		<dc:creator>Manoranjan</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://msahoo.wordpress.com/?p=163</guid>
		<description><![CDATA[This error occurred when  i tried to call Response.Redirect method from a class file. Then i tried to find the solution and i got to know that when we use the response object from an aspx page either from aspx page or it&#8217;s codebehind page, the response object is directly available because all these derived [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=163&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This error occurred when  i tried to call<span style="color:#008080;"> Response</span>.<span style="color:#0000ff;">Redirect </span>method from a class file. Then i tried to find the solution and i got to know that when we use the response object from an aspx page either from aspx page or it&#8217;s codebehind page, the response object is directly available because all  these derived from the page object.</p>
<p>When we use the response object in our own class, the object is not directly available, so we got this message.</p>
<p>Bbut we can use it by the following method :</p>
<p><span style="color:#008080;">HttpContext.Current.Response.Redirect(<span style="color:#800000;">“http://google.com”</span>);</span></p>
<p>Same problem happens when we tried to call a function from Response object.</p>
<p>Thank You.</p>
<br /> Tagged: <a href='http://msahoo.wordpress.com/tag/asp-net/'>ASP.Net</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/msahoo.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/msahoo.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/msahoo.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=msahoo.wordpress.com&amp;blog=7944611&amp;post=163&amp;subd=msahoo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://msahoo.wordpress.com/2010/03/16/asp-net-error-response-is-not-available-in-this-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2ad9e91c1f56d955b0adddbd780d99d0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msahoo</media:title>
		</media:content>
	</item>
	</channel>
</rss>
