<?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>Arjuntech's Weblog</title>
	<atom:link href="http://arjuntech.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://arjuntech.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 08 Sep 2011 07:00:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='arjuntech.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Arjuntech's Weblog</title>
		<link>http://arjuntech.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://arjuntech.wordpress.com/osd.xml" title="Arjuntech&#039;s Weblog" />
	<atom:link rel='hub' href='http://arjuntech.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ASP.NET- C#: Export datagrid rows to excel file</title>
		<link>http://arjuntech.wordpress.com/2011/09/08/asp-net-c-export-datagrid-rows-to-excel-file/</link>
		<comments>http://arjuntech.wordpress.com/2011/09/08/asp-net-c-export-datagrid-rows-to-excel-file/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 06:53:45 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=127</guid>
		<description><![CDATA[    public void ExportToExcel(string strFileName, DataGrid dataGrid)     {             Response.ClearContent();             string attachment = String.Concat(&#8220;attachment; filename=&#8221;, strFileName ,&#8221;.xls&#8221;);             Response.AddHeader(&#8220;content-disposition&#8221;, attachment);             Response.ContentType = &#8220;application/ms-excel&#8221;;             System.IO.StringWriter sw = new System.IO.StringWriter();             HtmlTextWriter htw = new HtmlTextWriter(sw);             dataGrid.RenderControl(htw);             Response.Write(sw.ToString());             Response.End();        }<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=127&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>    public void ExportToExcel(string strFileName, DataGrid dataGrid)<br />
    {<br />
            Response.ClearContent();<br />
            string attachment = String.Concat(&#8220;attachment; filename=&#8221;, strFileName ,&#8221;.xls&#8221;);<br />
            Response.AddHeader(&#8220;content-disposition&#8221;, attachment);<br />
            Response.ContentType = &#8220;application/ms-excel&#8221;;<br />
            System.IO.StringWriter sw = new System.IO.StringWriter();<br />
            HtmlTextWriter htw = new HtmlTextWriter(sw);<br />
            dataGrid.RenderControl(htw);<br />
            Response.Write(sw.ToString());<br />
            Response.End();<br />
       }</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/127/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/127/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/127/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=127&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2011/09/08/asp-net-c-export-datagrid-rows-to-excel-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Implementing IPostBackEventHandler in an ASP.NET Control</title>
		<link>http://arjuntech.wordpress.com/2011/09/08/implementing-ipostbackeventhandler-in-an-asp-net-control/</link>
		<comments>http://arjuntech.wordpress.com/2011/09/08/implementing-ipostbackeventhandler-in-an-asp-net-control/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 06:39:50 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=116</guid>
		<description><![CDATA[When creating a server control from scratch you must implement the IPostBackEventHandler interface if you want the control to handle postback events. If you’re extending an existing control and the control already implements this interface, then you simply need to override the IPostBackEventHandler methods to add your own postback events. The interface requires that a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=116&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p align="justify">When creating a server control from scratch you must implement the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.ipostbackeventhandler.aspx">IPostBackEventHandler</a> interface if you want the control to handle postback events. If you’re extending an existing control and the control already implements this interface, then you simply need to override the IPostBackEventHandler methods to add your own postback events.</p>
<p align="justify"><span id="more-116"></span></p>
<p align="justify">The interface requires that a single method be implemented:</p>
<div id="highlighter_974905">
<div><code>1.</code><code>public</code> <code>void</code> <code>RaisePostBackEvent(</code><code>string</code> <code>eventArgument) </code></div>
<div>
<div><code>2.</code><code>{ </code></div>
<div><code>3.</code><code>    </code><code>// raise control-specific events here </code></div>
<div><code>4.</code><code>}</code></div>
</div>
</div>
<p align="justify">RaisePostBackEvent is called on the IPostBackEventHandler control that raised the postback to the server. If an argument was passed to the server during the postback, it will be passed to the eventArgument parameter of the RaisePostBackEvent() method. But how does the server know which control raised the postback and how are any arguments passed back to the page? Let’s take a step back and look at how forms are submitted in HTML/JavaScript and how ASP.NET abstracts this behavior to provide us with the postback.</p>
<p><strong>Submitting a Form</strong></p>
<p align="justify">There are two mechanisms by which a form can be submitted to the server: an HTML submit button element or JavaScript. In order to use an HTML submit button, you must add the following markup to your form:</p>
<div id="highlighter_40447">
<div><code>1.</code><code>&lt;</code><code>input</code> <code>type</code><code>=</code><code>"submit"</code> <code>value</code><code>=</code><code>"Submit Form"</code> <code>/&gt;</code></div>
</div>
<p align="justify">This will render a simple button element which will display the text “Submit Form.” When clicked, the button will submit the form back to the server using an HTTP POST request. To do the same in JavaScript you simply need to retrieve the form DOM element and call its submit() function:</p>
<div id="highlighter_485331">
<div><code>1.</code><code>function</code> <code>submitForm() { </code></div>
<div>
<div><code>2.</code><code>    </code><code>document.forms[0].submit(); </code></div>
<div><code>3.</code><code>}</code></div>
</div>
</div>
<p align="justify">This will also cause the form to be submitted back to the server using an HTTP POST request.</p>
<p><strong>ASP.NET Postbacks</strong></p>
<p align="justify">The two methods described above are all that is required to create web applications that require any kind of interaction between client and server. ASP.NET provides many different kinds of controls which we can use to post our forms back to the server, but underneath all the layers of abstraction lie those two fundamental mechanisms.</p>
<p align="justify">For a page that uses any control except the Button and ImageButton (which we’ll take a look at momentarily), ASP.NET generates a simple JavaScript function and two hidden &lt;input /&gt; elements to handle form submissions:</p>
<div id="highlighter_911436">
<div><code>01.</code><code>&lt;input type=</code><code>"hidden"</code> <code>name=</code><code>"__EVENTTARGET"</code> <code>id=</code><code>"__EVENTTARGET"</code> <code>value=</code><code>""</code> <code>/&gt; </code></div>
<div>
<div><code>02.</code><code>&lt;input type=</code><code>"hidden"</code> <code>name=</code><code>"__EVENTARGUMENT"</code> <code>id=</code><code>"__EVENTARGUMENT"</code> <code>value=</code><code>""</code> <code>/&gt; </code></div>
<div><code>03.</code><code> </code> </div>
<div><code>04.</code><code>function</code> <code>__doPostBack(eventTarget, eventArgument) { </code></div>
<div><code>05.</code><code>    </code><code>if</code> <code>(!theForm.onsubmit || (theForm.onsubmit() != </code><code>false</code><code>)) { </code></div>
<div><code>06.</code><code>        </code><code>theForm.__EVENTTARGET.value = eventTarget; </code></div>
<div><code>07.</code><code>        </code><code>theForm.__EVENTARGUMENT.value = eventArgument; </code></div>
<div><code>08.</code><code>        </code><code>theForm.submit(); </code></div>
<div><code>09.</code><code>    </code><code>} </code></div>
<div><code>10.</code><code>}</code></div>
</div>
</div>
<p align="justify">Any time you interact with an ASP.NET control in a way the should cause a postback, this function is called. The two hidden fields, __EVENTTARGET and __EVENTARGUMENT, are used to keep track of the control which caused the postback and any data that should be associated with the control, respectively. These two fields can be access on the server in either the Page.Form or Page.Params collection. The first contains a collection of all form variables posted back to the server, and the second is a combined collection of form variables, query string variables, server variables, and cookies. The following code snippets are identical:</p>
<div id="highlighter_568511">
<div><code>1.</code><code>protected</code> <code>void</code> <code>Page_Load(</code><code>object</code> <code>sender, EventArgs e) </code></div>
<div>
<div><code>2.</code><code>{ </code></div>
<div><code>3.</code><code>    </code><code>var control = Request.Form[</code><code>"__EVENTTARGET"</code><code>]; </code></div>
<div><code>4.</code><code>    </code><code>var args = Request.Form[</code><code>"__EVENTARGUMENT"</code><code>]; </code></div>
<div><code>5.</code><code>}</code></div>
</div>
</div>
<div id="highlighter_46155">
<div><code></code> </div>
<div><code>1.</code><code>protected</code> <code>void</code> <code>Page_Load(</code><code>object</code> <code>sender, EventArgs e) </code></div>
<div>
<div><code>2.</code><code>{ </code></div>
<div><code>3.</code><code>    </code><code>var control = Request.Params[</code><code>"__EVENTTARGET"</code><code>]; </code></div>
<div><code>4.</code><code>    </code><code>var args = Request.Params[</code><code>"__EVENTARGUMENT"</code><code>]; </code></div>
<div><code>5.</code><code>}</code></div>
</div>
</div>
<p align="justify">This is how the server knows which control raised the postback and can call its RaisePostBackEvent() method, passing in the __EVENTARGUMENT data to the expected parameter.</p>
<p align="justify">The only exceptions to this rule are the Button and ImageButton controls. These controls are rendered as HTML submit button elements and therefore do not require any JavaScript to post the form and its data back to the server. These controls can still be identified when a postback is received by the server because they will be the only Button controls represented in the form collection.</p>
<p><strong>Enabling a Server Control to Cause a Postback</strong></p>
<p align="justify">So now that we know how postbacks work in ASP.NET, we need to add this functionality to the control that we want to implement the IPostBackEventHandler interface. After all, if the control doesn’t actually cause a postback, then the functions we implement as a part of that interface will be useless because they will never be called. Lucky for us, adding the client script necessary to cause a postback is pretty easy.</p>
<p align="justify">There are really two ways you can force your control to initiate a postback to the server. The first is to simply add a client event handler which fires off the __doPostBack() function, like so:</p>
<div id="highlighter_579035">
<div><code>1.</code><code>protected</code> <code>override</code> <code>void</code> <code>AddAttributesToRender(HtmlTextWriter writer) </code></div>
<div>
<div><code>2.</code><code>{ </code></div>
<div><code>3.</code><code>    </code><code>var script = String.Format(</code><code>"__doPostBack('{0}', '');"</code><code>, </code><code>this</code><code>.ClientID); </code></div>
<div><code>4.</code><code>    </code><code>writer.AddAttribute(HtmlTextWriterAttribute.Onclick, script); </code></div>
<div><code>5.</code><code>    </code><code>base</code><code>.AddAttributesToRender(writer); </code></div>
<div><code>6.</code><code>}</code></div>
</div>
</div>
<p align="justify">Here we’ve overridden the control’s <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webcontrol.addattributestorender.aspx">AddAttributesToRender()</a> method and added our own onclick client event handler to call __doPostBack(). I don’t really like this method because it feels clumsy. And remember, if you don’t have any other ASP.NET controls on your page that cause __doPostBack() to be rendered to the page, then you will see JavaScript exceptions when your control tries to call that function.</p>
<p align="justify">A better way to add the onclick client event handler would be to use the Page.ClientScriptManager’s <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx">GetPostBackEventReference()</a> method:</p>
<div id="highlighter_24890">
<div><code>1.</code><code>protected</code> <code>override</code> <code>void</code> <code>AddAttributesToRender(HtmlTextWriter writer) </code></div>
<div>
<div><code>2.</code><code>{ </code></div>
<div><code>3.</code><code>    </code><code>writer.AddAttribute(HtmlTextWriterAttribute.Onclick,  </code></div>
<div><code>4.</code><code>        </code><code>Page.ClientScript.GetPostBackEventReference(</code><code>this</code><code>, String.Empty)); </code></div>
<div><code>5.</code><code>    </code><code>base</code><code>.AddAttributesToRender(writer); </code></div>
<div><code>6.</code><code>}</code></div>
</div>
</div>
<p align="justify">Not only will this add the event handler for us, but it will also ensure the __doPostBack() function is inserted into our page for us.</p>
<p><strong>Bringing it all Together</strong></p>
<p align="justify">Now that we’ve taken a look at how this all works, let’s build a control so we can see these concepts in action. For this example I’m going to extend the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.aspx">Panel</a> control to create a simple ClickablePanel, which will fire off a postback to the server any time a user clicks inside the panel. The class should implement the IPostBackEventHandler interface by defining a RaisePostBackEvent() method. It will also define a single Click event, and will override the Panel’s AddAttributesToRender() method as demonstrated above. Here’s what the implementation should look like:</p>
<div id="highlighter_405893">
<div><code>01.</code><code>using</code> <code>System; </code></div>
<div>
<div><code>02.</code><code>using</code> <code>System.Web.UI; </code></div>
<div><code>03.</code><code>using</code> <code>System.Web.UI.WebControls; </code></div>
<div><code>04.</code><code> </code> </div>
<div><code>05.</code><code>namespace</code> <code>MyViewState.Examples.Web.Controls </code></div>
<div><code>06.</code><code>{ </code></div>
<div><code>07.</code><code>    </code><code>public</code> <code>class</code> <code>ClickablePanel : Panel, IPostBackEventHandler </code></div>
<div><code>08.</code><code>    </code><code>{ </code></div>
<div><code>09.</code><code>        </code><code>public</code> <code>ClickablePanel() </code></div>
<div><code>10.</code><code>            </code><code>: </code><code>base</code><code>() </code></div>
<div><code>11.</code><code>        </code><code>{ } </code></div>
<div><code>12.</code><code> </code> </div>
<div><code>13.</code><code>        </code><code>private</code> <code>EventHandler _click; </code></div>
<div><code>14.</code><code>        </code><code>public</code> <code>event</code> <code>EventHandler Click </code></div>
<div><code>15.</code><code>        </code><code>{ </code></div>
<div><code>16.</code><code>            </code><code>add { _click += value; } </code></div>
<div><code>17.</code><code>            </code><code>remove { _click -= value; } </code></div>
<div><code>18.</code><code>        </code><code>} </code></div>
<div><code>19.</code><code> </code> </div>
<div><code>20.</code><code>        </code><code>protected</code> <code>virtual</code> <code>void</code> <code>FireClickEvent() </code></div>
<div><code>21.</code><code>        </code><code>{ </code></div>
<div><code>22.</code><code>            </code><code>if</code> <code>(_click != </code><code>null</code><code>) </code></div>
<div><code>23.</code><code>                </code><code>_click(</code><code>this</code><code>, </code><code>new</code> <code>EventArgs()); </code></div>
<div><code>24.</code><code>        </code><code>} </code></div>
<div><code>25.</code><code> </code> </div>
<div><code>26.</code><code>        </code><code>protected</code> <code>override</code> <code>void</code> <code>AddAttributesToRender(HtmlTextWriter writer) </code></div>
<div><code>27.</code><code>        </code><code>{ </code></div>
<div><code>28.</code><code>            </code><code>writer.AddAttribute(HtmlTextWriterAttribute.Onclick,  </code></div>
<div><code>29.</code><code>                </code><code>Page.ClientScript.GetPostBackEventReference(</code><code>this</code><code>, String.Empty)); </code></div>
<div><code>30.</code><code>            </code><code>base</code><code>.AddAttributesToRender(writer); </code></div>
<div><code>31.</code><code>        </code><code>} </code></div>
<div><code>32.</code><code> </code> </div>
<div><code>33.</code><code>        </code><code>public</code> <code>void</code> <code>RaisePostBackEvent(</code><code>string</code> <code>eventArgument) </code></div>
<div><code>34.</code><code>        </code><code>{ </code></div>
<div><code>35.</code><code>            </code><code>FireClickEvent(); </code></div>
<div><code>36.</code><code>        </code><code>} </code></div>
<div><code>37.</code><code>    </code><code>} </code></div>
<div><code>38.</code><code>}</code></div>
</div>
</div>
<p align="justify">Now you can add a ClickablePanel to any ASP.NET page or user control and handle its Click event to add your own logic.</p>
<div id="highlighter_259181">
<div><code>01.</code><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="MyViewState.Examples.Web._Default" %&gt; </code></div>
<div>
<div><code>02.</code><code>&lt;%@ Register Assembly="MyViewState.Examples.Web" Namespace="MyViewState.Examples.Web.Controls" TagPrefix="controls" %&gt; </code></div>
<div><code>03.</code><code> </code> </div>
<div><code>04.</code><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"&gt; </code></div>
<div><code>05.</code><code> </code> </div>
<div><code>06.</code><code>&lt;</code><code>html</code> <code>xmlns</code><code>=</code><code>"<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"</code> <code>&gt; </code></div>
<div><code>07.</code><code>&lt;</code><code>head</code> <code>runat</code><code>=</code><code>"server"</code><code>&gt; </code></div>
<div><code>08.</code><code>    </code><code>&lt;</code><code>title</code><code>&gt;Example - Implementing IPostBackEventHandler in an ASP.NET Control&lt;/</code><code>title</code><code>&gt; </code></div>
<div><code>09.</code><code>&lt;/</code><code>head</code><code>&gt; </code></div>
<div><code>10.</code><code>&lt;</code><code>body</code><code>&gt; </code></div>
<div><code>11.</code><code>    </code><code>&lt;</code><code>form</code> <code>id</code><code>=</code><code>"form1"</code> <code>runat</code><code>=</code><code>"server"</code><code>&gt; </code></div>
<div><code>12.</code><code>        </code><code>&lt;</code><code>controls:ClickablePanel</code> <code>ID</code><code>=</code><code>"ClickablePanel"</code> <code>runat</code><code>=</code><code>"server"</code></div>
<div><code>13.</code><code>            </code><code>BackColor</code><code>=</code><code>"Blue"</code></div>
<div><code>14.</code><code>            </code><code>Height</code><code>=</code><code>"200px"</code></div>
<div><code>15.</code><code>            </code><code>Width</code><code>=</code><code>"400px"</code><code>&gt; </code></div>
<div><code>16.</code><code>        </code><code>&lt;/</code><code>controls:ClickablePanel</code><code>&gt; </code></div>
<div><code>17.</code><code>        </code><code>&lt;</code><code>asp:Literal</code> <code>ID</code><code>=</code><code>"litMessage"</code> <code>runat</code><code>=</code><code>"server"</code> <code>/&gt; </code></div>
<div><code>18.</code><code>    </code><code>&lt;/</code><code>form</code><code>&gt; </code></div>
<div><code>19.</code><code>&lt;/</code><code>body</code><code>&gt; </code></div>
<div><code>20.</code><code>&lt;/</code><code>html</code><code>&gt;</code></div>
</div>
</div>
<div id="highlighter_700789">
<div><code></code> </div>
<div><code>01.</code><code>using</code> <code>System; </code></div>
<div>
<div><code>02.</code><code>using</code> <code>MyViewState.Examples.Web.Controls; </code></div>
<div><code>03.</code><code> </code> </div>
<div><code>04.</code><code>namespace</code> <code>MyViewState.Examples.Web </code></div>
<div><code>05.</code><code>{ </code></div>
<div><code>06.</code><code>    </code><code>public</code> <code>partial </code><code>class</code> <code>_Default : System.Web.UI.Page </code></div>
<div><code>07.</code><code>    </code><code>{ </code></div>
<div><code>08.</code><code>        </code><code>protected</code> <code>override</code> <code>void</code> <code>OnLoad(EventArgs e) </code></div>
<div><code>09.</code><code>        </code><code>{ </code></div>
<div><code>10.</code><code>            </code><code>base</code><code>.OnLoad(e); </code></div>
<div><code>11.</code><code>            </code><code>ClickablePanel.Click += </code><code>new</code> <code>EventHandler(ClickablePanel_Click); </code></div>
<div><code>12.</code><code>        </code><code>} </code></div>
<div><code>13.</code><code> </code> </div>
<div><code>14.</code><code>        </code><code>protected</code> <code>void</code> <code>ClickablePanel_Click(</code><code>object</code> <code>sender, EventArgs e) </code></div>
<div><code>15.</code><code>        </code><code>{ </code></div>
<div><code>16.</code><code>            </code><code>var message = String.Format(</code><code>"You clicked the panel at {0}."</code><code>, DateTime.Now.ToLongTimeString()); </code></div>
<div><code>17.</code><code>            </code><code>litMessage.Text = message; </code></div>
<div><code>18.</code><code>        </code><code>} </code></div>
<div><code>19.</code><code>    </code><code>} </code></div>
<div><code>20.</code><code>}</code></div>
</div>
</div>
<p align="justify">Now when we run this, we&#8217;ll see the following markup when the page is rendered to the browser:</p>
<div id="highlighter_507725">
<div><code>01.</code><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>"&gt;  </code></div>
<div>
<div><code>02.</code><code>&lt;</code><code>html</code> <code>xmlns</code><code>=</code><code>"<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"</code> <code>&gt; </code></div>
<div><code>03.</code><code>&lt;</code><code>head</code><code>&gt; </code></div>
<div><code>04.</code><code>    </code><code>&lt;</code><code>title</code><code>&gt; </code></div>
<div><code>05.</code><code>        </code><code>Example - Implementing IPostBackEventHandler in an ASP.NET Control </code></div>
<div><code>06.</code><code>    </code><code>&lt;/</code><code>title</code><code>&gt; </code></div>
<div><code>07.</code><code>&lt;/</code><code>head</code><code>&gt; </code></div>
<div><code>08.</code><code>&lt;</code><code>body</code><code>&gt; </code></div>
<div><code>09.</code><code>    </code><code>&lt;</code><code>form</code> <code>name</code><code>=</code><code>"form1"</code> <code>method</code><code>=</code><code>"post"</code> <code>action</code><code>=</code><code>"Default.aspx"</code> <code>id</code><code>=</code><code>"form1"</code><code>&gt; </code></div>
<div><code>10.</code><code>        </code><code>&lt;</code><code>div</code><code>&gt; </code></div>
<div><code>11.</code><code>            </code><code>&lt;</code><code>input</code> <code>type</code><code>=</code><code>"hidden"</code> <code>name</code><code>=</code><code>"__VIEWSTATE"</code> <code>id</code><code>=</code><code>"__VIEWSTATE"</code> </div>
<div><code>12.</code><code>                </code><code>value</code><code>=</code><code>"/wEPDwUKMTUzMzI3OTIxNGRkj5tANgOC/iyQIg7/hT+BzVmVUQo="</code> <code>/&gt; </code></div>
<div><code>13.</code><code>        </code><code>&lt;/</code><code>div</code><code>&gt;  </code></div>
<div><code>14.</code><code>        </code><code>&lt;</code><code>div</code><code>&gt;  </code></div>
<div><code>15.</code><code>            </code><code>&lt;</code><code>input</code> <code>type</code><code>=</code><code>"hidden"</code> <code>name</code><code>=</code><code>"__EVENTTARGET"</code> <code>id</code><code>=</code><code>"__EVENTTARGET"</code> <code>value</code><code>=</code><code>""</code> <code>/&gt; </code></div>
<div><code>16.</code><code>            </code><code>&lt;</code><code>input</code> <code>type</code><code>=</code><code>"hidden"</code> <code>name</code><code>=</code><code>"__EVENTARGUMENT"</code> <code>id</code><code>=</code><code>"__EVENTARGUMENT"</code> <code>value</code><code>=</code><code>""</code> <code>/&gt; </code></div>
<div><code>17.</code><code>        </code><code>&lt;/</code><code>div</code><code>&gt; </code></div>
<div><code>18.</code><code>        </code><code>&lt;</code><code>div</code> <code>onclick</code><code>=</code><code>"__doPostBack('ClickablePanel','')"</code> <code>id</code><code>=</code><code>"ClickablePanel"</code> </div>
<div><code>19.</code><code>            </code><code>style</code><code>=</code><code>"background-color:Blue;height:300px;width:500px;"</code><code>&gt; </code></div>
<div><code>20.</code><code>        </code><code>&lt;/</code><code>div</code><code>&gt;     </code></div>
<div><code>21.</code><code>        </code><code>&lt;</code><code>script</code> <code>type</code><code>=</code><code>"text/javascript"</code><code>&gt; </code></div>
<div><code>22.</code><code>            </code><code>//</code><code>&lt;![CDATA[ </code></div>
<div><code>23.</code><code>            </code><code>var theForm = document.forms['form1']; </code></div>
<div><code>24.</code><code>            </code><code>if (!theForm) { </code></div>
<div><code>25.</code><code>                </code><code>theForm = document.form1; </code></div>
<div><code>26.</code><code>            </code><code>} </code></div>
<div><code>27.</code><code>            </code><code>function __doPostBack(eventTarget, eventArgument) { </code></div>
<div><code>28.</code><code>                </code><code>if (!theForm.onsubmit || (theForm.onsubmit() != false)) { </code></div>
<div><code>29.</code><code>                    </code><code>theForm.__EVENTTARGET.value = eventTarget; </code></div>
<div><code>30.</code><code>                    </code><code>theForm.__EVENTARGUMENT.value = eventArgument; </code></div>
<div><code>31.</code><code>                    </code><code>theForm.submit(); </code></div>
<div><code>32.</code><code>                </code><code>} </code></div>
<div><code>33.</code><code>            </code><code>} </code></div>
<div><code>34.</code><code>            </code><code>//]]&gt;</code></div>
<div><code>35.</code><code>        </code><code>&lt;/</code><code>script</code><code>&gt;  </code></div>
<div><code>36.</code><code>    </code><code>&lt;/</code><code>form</code><code>&gt; </code></div>
<div><code>37.</code><code>&lt;/</code><code>body</code><code>&gt; </code></div>
<div><code>38.</code><code>&lt;/</code><code>html</code><code>&gt;</code></div>
</div>
</div>
<p align="justify">Notice the control is rendered as a &lt;div&gt; element with an onclick event handler that calls __doPostBack(). And if we click on the panel, the form is posted back to the server, the Click event is raised, and the message below the panel is updated.</p>
<p align="justify"> </p>
<p><strong>Wrap Up</strong></p>
<p align="justify">Implementing an interface with a single method should be a pretty simple task. I went a little overboard describing how to implement the IPostBackEventHandler interface, but hopefully now you have all the why’s and how’s to take with you when building your own ASP.NET server controls. If you’re interested in taking this knowledge even further, then I recommend checking out the <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.ipostbackdatahandler.aspx">IPostBackDataHandler</a>, which you must implement if your control needs to examine any data that is posted back by the client.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/116/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/116/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/116/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=116&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2011/09/08/implementing-ipostbackeventhandler-in-an-asp-net-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Disabling button at client side before firing server side event</title>
		<link>http://arjuntech.wordpress.com/2011/09/07/disabling-button-at-client-side-before-firing-server-side-event/</link>
		<comments>http://arjuntech.wordpress.com/2011/09/07/disabling-button-at-client-side-before-firing-server-side-event/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 09:03:54 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=88</guid>
		<description><![CDATA[Many a times it&#8217;s required to disable the button at client side before firing the server side event. One best example is while processing credit card payments, the button has to be disabled until the card details are processed which is a time consuming job. This may sometimes seem to be unresponsive, so if the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=88&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Many a times it&#8217;s required to disable the button at client side before firing the server side event. One best example is while processing credit card payments, the button has to be disabled until the card details are processed which is a time consuming job. This may sometimes seem to be unresponsive, so if the user clicks the button once again the risk is that payment may get processed twice.</p>
<p><span id="more-88"></span></p>
<p>So to avoid this it&#8217;s a best practise to disable the button at client side once the user clicks the button and reenable it after the processing is complete. Disabling the button can be achieved through simple javascript function and an attribute. But the problem is the server side event doesn&#8217;t get fired once the button is disabled using javascript.</p>
<p>I found a cool feature to overcome this in ASP.NET 2.0 ClientScript.GetPostBackEventReference. The main function of ClientScript.GetPostBackEventReference is that it returns a string that can be used in a client event to cause postback to the server. <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx">http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.getpostbackeventreference.aspx</a></p>
<p>Code</p>
<p> <br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
btnClick.Attributes.Add(&#8220;onclick&#8221;, ClientScript.GetPostBackEventReference(btnClick, &#8220;&#8221;) + &#8220;;this.value=&#8217;Processing Credit Card Payment&#8230;&#8217;;this.disabled = true;&#8221;);<br />
}<br />
protected void btnClick_Click(object sender, EventArgs e)<br />
{<br />
System.Threading.Thread.Sleep(2000);<br />
}</p>
<p><strong>ASPX Page</strong></p>
<p>&lt;%@ Page Language=&#8221;C#&#8221; AutoEventWireup=&#8221;true&#8221; CodeFile=&#8221;Default.aspx.cs&#8221; Inherits=&#8221;_Default&#8221; %&gt;</p>
<p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</p>
<p>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; &gt;</p>
<p>&lt;head runat=&#8221;server&#8221;&gt;</p>
<p>&lt;title&gt;Untitled Page&lt;/title&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;</p>
<p>&lt;div&gt;</p>
<p>&lt;asp:Button ID=&#8221;btnClick&#8221; runat=&#8221;server&#8221; Text=&#8221;ClickMe&#8221; OnClick=&#8221;btnClick_Click&#8221; /&gt;</p>
<p>&lt;/div&gt;</p>
<p>&lt;/form&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>&lt;h2&gt;<br />
<strong>This would do the job perfectly!</strong><br />
&lt;/h2&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/88/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/88/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/88/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=88&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2011/09/07/disabling-button-at-client-side-before-firing-server-side-event/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.NET and AJAX Basic Training</title>
		<link>http://arjuntech.wordpress.com/2010/06/23/asp-net-and-ajax-basic-training/</link>
		<comments>http://arjuntech.wordpress.com/2010/06/23/asp-net-and-ajax-basic-training/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 09:37:55 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=75</guid>
		<description><![CDATA[ASP.NET and AJAX Basic Training ppt. PPT Contents What is ASP.NET?  ASP.NET Versions Difference Between ASP and ASP.NET ASP.NET Architecture Overview ASP.NET IIS life cycle Overview ASP.NET Page life cycle Overview ASP.NET State Management Overview ASP.NET Security JavaScript, CSS file Walkthrough Creating Webpage in ASP.NET Ajax- Introduction<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=75&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://arjuntech.files.wordpress.com/2010/06/asp-net-and-ajax-training.ppt">ASP.NET and AJAX Basic Training ppt</a>.</p>
<p>PPT Contents</p>
<ul>
<li>What is ASP.NET? </li>
<li>ASP.NET Versions</li>
<li>Difference Between ASP and ASP.NET</li>
<li>ASP.NET Architecture Overview</li>
<li>ASP.NET IIS life cycle Overview</li>
<li>ASP.NET Page life cycle Overview</li>
<li>ASP.NET State Management Overview</li>
<li>ASP.NET Security</li>
<li>JavaScript, CSS file</li>
<li>Walkthrough Creating Webpage in ASP.NET</li>
<li>Ajax- Introduction</li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=75&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2010/06/23/asp-net-and-ajax-basic-training/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Microsoft Visual C# Default Keybindings</title>
		<link>http://arjuntech.wordpress.com/2010/06/01/microsoft-visual-c-default-keybindings/</link>
		<comments>http://arjuntech.wordpress.com/2010/06/01/microsoft-visual-c-default-keybindings/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 11:47:44 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=62</guid>
		<description><![CDATA[Microsoft® Visual C#® Default Keybindings<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=62&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a class="aligncenter" title="Microsoft® Visual C#® Default Keybindings" href="http://arjuntech.files.wordpress.com/2010/06/microsoftc2ae-visual-cc2ae-default-keybindings.pdf" target="_blank">Microsoft® Visual C#® Default Keybindings</p>
<p></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=62&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2010/06/01/microsoft-visual-c-default-keybindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Clear all form fields using javascript</title>
		<link>http://arjuntech.wordpress.com/2010/01/12/clear-all-form-fields/</link>
		<comments>http://arjuntech.wordpress.com/2010/01/12/clear-all-form-fields/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 09:25:48 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=23</guid>
		<description><![CDATA[Below generic code used to clear the form fields in asp or asp.net webpage. This code is written in JavaScript to avoid postback to server.  JavaScript Code: function ClearAllFields() {     for (var count = 0; count &#60; document.forms.length; count++) {         for (var eleCount = 0; eleCount &#60; document.forms[count].elements.length; eleCount++) {             if (document.forms[count].elements[eleCount].type == &#8216;text&#8217;) {                 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=23&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Below generic code used to clear the form fields in asp or asp.net webpage. This code is written in JavaScript to avoid postback to server. </p>
<p><span id="more-23"></span></p>
<p><span style="text-decoration:underline;">JavaScript Code:</span></p>
<p><em>function ClearAllFields() {</em></p>
<address><em>    for (var count = 0; count &lt; document.forms.length; count++) {</em></address>
<address><em>        for (var eleCount = 0; eleCount &lt; document.forms[count].elements.length; eleCount++) {</em></address>
<address><em>            if (document.forms[count].elements[eleCount].type == &#8216;text&#8217;) {</em></address>
<address><em>                document.forms[count].elements[eleCount].value = &#8221;;</em></address>
<address><em>                document.forms[count].elements[eleCount].readOnly = false;</em></address>
<address><em>            }</em></address>
<address><em>            else if (document.forms[count].elements[eleCount].type == &#8216;checkbox&#8217;) {</em></address>
<address><em>            document.forms[count].elements[eleCount].checked = false;</em></address>
<address><em>            document.forms[count].elements[eleCount].disabled = false;</em></address>
<address><em>            }</em></address>
<address><em>            else if (document.forms[count].elements[eleCount].type == &#8216;select-one&#8217;) {</em></address>
<address><em>            document.forms[count].elements[eleCount].selectedIndex = 0;</em></address>
<address><em>            document.forms[count].elements[eleCount].disabled = false;</em></address>
<address><em>            }</em></address>
<address><em>            else if (document.forms[count].elements[eleCount].type == &#8216;textarea&#8217;) {</em></address>
<address><em>            document.forms[count].elements[eleCount].value = &#8221;;</em></address>
<address><em>            document.forms[count].elements[eleCount].readOnly = false;</em></address>
<address><em>            }</em></address>
<address><em>            else if (document.forms[count].elements[eleCount].type == &#8216;select-multiple&#8217;) {</em></address>
<address><em>            document.forms[count].elements[eleCount].selectedIndex = -1;</em></address>
<address><em>            document.forms[count].elements[eleCount].disabled = false;</em></address>
<address><em>            }</em></address>
<address><em>        }</em></address>
<address><em>    }</em></address>
<address><em>    return false;</em></address>
<address><em>}</em></address>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=23&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2010/01/12/clear-all-form-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Upload and Download Files In ASP.NET</title>
		<link>http://arjuntech.wordpress.com/2008/05/14/upload-and-download-files-using-aspnet/</link>
		<comments>http://arjuntech.wordpress.com/2008/05/14/upload-and-download-files-using-aspnet/#comments</comments>
		<pubDate>Wed, 14 May 2008 06:50:09 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=22</guid>
		<description><![CDATA[FileUpload Class: The fileupload class display a textbox and browse button that enable user to select an file on client side and upload it to the web server. Either user can type full file path in textbox or can select file by clicking the browse button and locating file it in the choose file dialog box. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=22&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>FileUpload Class: The fileupload class display a textbox and browse button that enable user to select an file on client side and upload it to the web server. Either user can type full file path in textbox or can select file by clicking the browse button and locating file it in the choose file dialog box.</p>
<p>The Fileupload control does not automatically save a file to server after user have selects files to upload. you must explicit provide a control to allow user to upload specified file.For example , you can provide button that the user click to upload the file.</p>
<p><span id="more-22"></span></p>
<p>Write below code in update button click</p>
<p>Protected void btnUpload_Click(object sender, EventArgs e)</p>
<p>{</p>
<p>if (( FileUpload1.PostedFile!=null) &amp;&amp;  FileUpload1.PostedFile.ContentLength &gt;0)</p>
<p>{</p>
<p>String fileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);</p>
<p>// Create folder in server and name it as &#8220;Upload files&#8221;. so the user can upload their file in this location</p>
<p>String saveLocation = String.Concat(Server.MapPath(&#8220;Upload files&#8221;), &#8220;\\&#8221;, fileName);</p>
<p>}</p>
<p>         try     { </p>
<p>                 if (FileUpload1.HasFile)   {</p>
<p>                 FileUpload1.PostedFile.SaveAs(saveLocation);</p>
<p>                 Response.Write(&#8220;The file has been uploaded.&#8221;);</p>
<p>                }</p>
<p>              catch (Exception ex) { Response.Write(&#8220;Error: &#8221; + ex.Message);}</p>
<p>}</p>
<p>Before calling <strong>SaveAs</strong> method to save the file to the server, use the <strong>HasFile</strong>properties to verfiy that the fileupload contains a file. if the HasFile return true,call the saveas method,it return false means fileupload does not contain file.</p>
<p>SaveAs method writes the upload file to specified directory, so that create directory for example &#8220;Upload files&#8221; give the directory path in SaveAs method as parameter. application must have writing access to the directory on the server.</p>
<p>limit the size of the files that can be uploaded by using the <span class="selflink">FileUpload</span> control. You should set a size limit that is appropriate for the types of files that you expect to be uploaded. The default size limit is 4096 kilobytes (KB), or 4 megabytes (MB). To increase the maximum allowable file size for the entire application, set the <span class="keyword">maxRequestLength</span>attribute in the Web.config file. To increase the maximum allowable file size for a specified page, set the <span class="keyword">maxRequestLength</span> attribute inside the <span class="keyword">location</span>element in Web.config.</p>
<p>For Example</p>
<p><span style="font-size:x-small;color:#0000ff;">&lt;</span><span style="font-size:x-small;color:#800000;">system.web</span><span style="font-size:x-small;color:#0000ff;">&gt;&lt;</span><span style="font-size:x-small;color:#800000;">httpRuntime</span><span style="font-size:x-small;color:#0000ff;"> </span><span style="font-size:x-small;color:#ff0000;">maxRequestLength</span><span style="font-size:x-small;color:#0000ff;"> =</span><span style="font-size:x-small;">&#8220;</span><span style="font-size:x-small;color:#0000ff;">90000</span><span style="font-size:x-small;">&#8220;</span><span style="font-size:x-small;color:#0000ff;">/&gt; </span><span style="font-size:x-small;color:#0000ff;"><span style="font-size:x-small;color:#0000ff;">&lt;/</span><span style="font-size:x-small;color:#800000;">system.web</span><span style="font-size:x-small;color:#0000ff;">&gt;</span></span></p>
<p><strong>Download Files Coding</strong></p>
<p><span style="font-size:x-small;"> </span>Response.Clear()</p>
<p>Response.AddHeader(<span style="font-size:x-small;color:#800000;">&#8220;Content-Disposition&#8221;</span><span style="font-size:x-small;">, </span><span style="font-size:x-small;color:#800000;">&#8220;attachment;filename=&#8221;</span><span style="font-size:x-small;"> &amp; file.Name)</span></p>
<p><span style="font-size:x-small;">Response.WriteFile(file.FullName)</span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/arjuntech.wordpress.com/22/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/arjuntech.wordpress.com/22/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/22/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/22/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/22/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=22&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2008/05/14/upload-and-download-files-using-aspnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>How to connect database using System.Data.Common</title>
		<link>http://arjuntech.wordpress.com/2008/04/22/how-to-connect-database-using-systemdatacommon/</link>
		<comments>http://arjuntech.wordpress.com/2008/04/22/how-to-connect-database-using-systemdatacommon/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 11:03:20 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=20</guid>
		<description><![CDATA[In .NET application if developer wants to access SQL database then have to use using System.Data.SqlClient namespace, for oracle using Sytem.Data.OracleClient namespace, for MS-Access using System.Data.OleDb namespace.Suppose developer wants to access database based on user selected database(SQL or Orcale or MS-Access) in GUI application,then developer have use System.Data.Common namespace to access seleted database.If it&#8217;s single [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=20&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">In .NET application if developer wants to access SQL database then have to use using System.Data.SqlClient namespace, for oracle using Sytem.Data.OracleClient namespace, for MS-Access using System.Data.OleDb namespace.Suppose developer wants to access database based on user selected database(SQL or Orcale or MS-Access) in GUI application,then developer have use System.Data.Common namespace to access seleted database.If it&#8217;s single database developer can use that database namespace. If it&#8217;s multiple database then use have to use System.Data.Common namespace.</p>
<p><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Times New Roman;font-size:small;">DownLoadSampleCode: <span style="text-decoration:underline;">S</span></span><a href="http://arjuntech.files.wordpress.com/2008/04/systemdatacommon.doc"><span style="color:windowtext;"><span style="font-family:Times New Roman;font-size:small;">ystem.Data.Common</span></span></a></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span> <span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"> </span></span></span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"> </span></span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span></span><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"> </span></span></span><span style="font-size:small;"><span style="font-size:small;"> </span></span><span style="font-size:small;"> </span>  </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-align:justify;">
<p class="MsoNormal" style="text-align:justify;margin:0;">
<p style="text-align:justify;">    </p>
<pre style="text-align:justify;"> 
<span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"><span style="font-family:Verdana;color:#000000;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="color:#000000;"><span style="font-size:small;"><span style="font-size:small;"><span style="font-family:Times New Roman;"><span style="font-family:Verdana;color:#000000;"> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/arjuntech.wordpress.com/20/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/arjuntech.wordpress.com/20/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=20&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2008/04/22/how-to-connect-database-using-systemdatacommon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Manipulate string array using stringcollection</title>
		<link>http://arjuntech.wordpress.com/2008/03/12/manipulate-string-array-using-stringcollection/</link>
		<comments>http://arjuntech.wordpress.com/2008/03/12/manipulate-string-array-using-stringcollection/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 11:48:31 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=17</guid>
		<description><![CDATA[It very difficult to add or insert or delete a string in array,but using System.Collections.Specialized.StringCollection();we can manipulate   string array rapidly.    Sample Code:   private String[] strArray = new String[] {};   ///Write this Code in  Constructor strCollection = new System.Collections.Specialized.StringCollection(); strCollection.AddRange(strArray); //Add String  strCollection.Add(richTextBox1.Text.Trim());  richTextBox1.Text = string.Empty;   // Display StringArray  StringBuildersb = new StringBuilder();  for (inti [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=17&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It very difficult to add or insert or delete a string in array,but using<br />
System.Collections.Specialized.StringCollection();we can manipulate  </p>
<p>string array rapidly.   </p>
<div>Sample Code:</div>
<div> </div>
<div>
<p>private String[] strArray = new String[] {}; </p>
<p> ///Write this Code in  Constructor</p>
<p>strCollection = new System.Collections.Specialized.StringCollection();</p>
<p>strCollection.AddRange(strArray);</p>
<p><strong><span style="text-decoration:underline;">//Add String</span></strong> </p>
<p>strCollection.Add(richTextBox1.Text.Trim()); </p>
<p>richTextBox1.Text = string.Empty;  </p>
<p><strong><span style="text-decoration:underline;">// Display StringArray</span></strong> </p>
<p>StringBuildersb = new StringBuilder(); </p>
<p>for (inti = 0; i &lt; strCollection.Count; i++) </p>
<p>{ </p>
<p>sb.Append(strCollection[i]); </p>
<p>sb.Append(Environment.NewLine);  </p>
<p>} </p>
<p>richTextBox2.Text = sb.ToString(); </p>
<p><strong><span style="text-decoration:underline;">// Get the String Array</span></strong> </p>
<p>strArray = new String[strCollection.Count];  </p>
<p>strCollection.CopyTo(strArray, 0); </p>
<p>return strArray; </p>
<p><strong><span style="text-decoration:underline;">// Remove String</span></strong>  </p>
<p>strCollection.Remove(“Value”) ; </p>
<p>strCollection.RemoveAt(index); </p>
<p><strong><span style="text-decoration:underline;">// Get the Index of Array</span></strong>  </p>
<p>strCollection.IndexOf(“Value”) </p>
<p>strCollection.Insert(index,“value”) </p>
</div>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/arjuntech.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/arjuntech.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=17&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2008/03/12/manipulate-string-array-using-stringcollection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
		<item>
		<title>Xml Validating Reader</title>
		<link>http://arjuntech.wordpress.com/2008/03/06/xml-validating-reader/</link>
		<comments>http://arjuntech.wordpress.com/2008/03/06/xml-validating-reader/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 12:13:59 +0000</pubDate>
		<dc:creator>arjuntech</dc:creator>
				<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://arjuntech.wordpress.com/?p=16</guid>
		<description><![CDATA[Before seeing  Xml Validation Reader let us see XSD (Xml Schema Definition) What is XSD? XSD provides the syntax and defines a way in which element and attributes can represent in Xml Documents. Below sample code based on XSD file XML file will be validate. In case any error validationEventHandler will invoke and display the error  // [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=16&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Before seeing  Xml Validation Reader let us see XSD (Xml Schema Definition)</p>
<p>What is XSD?</p>
<p>XSD provides the syntax and defines a way in which element and attributes can represent in Xml Documents.</p>
<p><span id="more-16"></span></p>
<p>Below sample code based on XSD file XML file will be validate. In case any error validationEventHandler will invoke and display the error<font size="2" face="Courier New"> </font></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span> </span><span style="color:green;">// path&#8217;s to xml/xsd</span></span><span style="font-size:10pt;font-family:'Courier New';"><span>    </span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:blue;">const</span> <span style="color:blue;">string</span>xmlPath = @&#8221;\sample.xml&#8221;;</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:blue;">const</span> <span style="color:blue;">string</span>xsdPath = @&#8221;\sample.xsd&#8221;;</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// Create a new validating reader</span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">XmlValidatingReader reader = <span style="color:blue;">new</span> XmlValidatingReader(<span style="color:blue;">new</span>XmlTextReader(<span style="color:blue;">new</span>StreamReader(xmlPath)));</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// Create a schema collection, add the xsd to it</span></span><span style="font-size:10pt;font-family:'Courier New';"><span>                  </span>XmlSchemaCollection schemaCollection = <span style="color:blue;">new</span> XmlSchemaCollection();</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">schemaCollection.Add(&#8220;http://detail.franchise.scarlett&#8221;,xsdPath);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// Add the schema collection to the XmlValidatingReader</span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;"></span></span><span style="font-size:10pt;font-family:'Courier New';">reader.Schemas.Add(schemaCollection);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">Console.Write(&#8220;Validating&#8230;.&#8221;);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// Wire up the call back.<span>  </span>The ValidationEvent is fired when the</span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// XmlValidatingReader hits an issue validating a section of the xml</span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">reader.ValidationEventHandler += <span style="color:blue;">new</span> ValidationEventHandler (reader_ValidationEventHandler);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;">// Iterate through the xml document</span></span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:green;"></span></span><span style="font-size:10pt;font-family:'Courier New';"><span style="color:blue;">while</span>(reader.Read())</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">{</span><span style="font-size:10pt;font-family:'Courier New';">Console.Write(<font size="2">reader.Value</font>);</span><span style="font-size:10pt;font-family:'Courier New';">}</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">Console.WriteLine(&#8220;\n&#8221;);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">Console.ReadLine();</span><span style="font-size:10pt;font-family:'Courier New';">}</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"><span style="color:blue;">private</span> <span style="color:blue;">void</span> reader_ValidationEventHandler(<span style="color:blue;">object</span> sender, ValidationEventArgs e)</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">{</span><span style="font-size:10pt;font-family:'Courier New';">Console.WriteLine(&#8220;Error&#8221;);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';">Console.WriteLine(e.Exception.Message);</span></p>
<p><span style="font-size:10pt;font-family:'Courier New';"></span><span style="font-size:10pt;font-family:'Courier New';">Console.WriteLine(e.Exception.LineNumber);</span><span style="font-size:10pt;font-family:'Courier New';">}</span><span style="font-size:10pt;font-family:'Courier New';">}</span><span style="font-size:10pt;font-family:'Courier New';">}</span> </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/arjuntech.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/arjuntech.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/arjuntech.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/arjuntech.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/arjuntech.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=arjuntech.wordpress.com&amp;blog=2255577&amp;post=16&amp;subd=arjuntech&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://arjuntech.wordpress.com/2008/03/06/xml-validating-reader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e359b8ddac1fa3095d61f70f0fb0f281?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">arjuntech</media:title>
		</media:content>
	</item>
	</channel>
</rss>
