<?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>DotNet Strings</title>
	<atom:link href="http://shyleshgov.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://shyleshgov.wordpress.com</link>
	<description>.Net Development</description>
	<lastBuildDate>Thu, 09 Jun 2011 06:38:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='shyleshgov.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>DotNet Strings</title>
		<link>http://shyleshgov.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://shyleshgov.wordpress.com/osd.xml" title="DotNet Strings" />
	<atom:link rel='hub' href='http://shyleshgov.wordpress.com/?pushpress=hub'/>
		<item>
		<title>MVP design pattern of ASP.NET</title>
		<link>http://shyleshgov.wordpress.com/2011/06/09/mvp-design-pattern-of-asp-net/</link>
		<comments>http://shyleshgov.wordpress.com/2011/06/09/mvp-design-pattern-of-asp-net/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 06:29:08 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=188</guid>
		<description><![CDATA[The MVP is Model, View , Presenter. This pattern is how the interaction between these layers can be done. View: View can be your Aspx page in your web applications or any user controls/Interface for the end user. Model: Contains all the business logic. Presenter: Works as the intermediate agent for Model and View. It [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=188&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The MVP is Model, View , Presenter. This pattern is how the interaction between these layers can be done. </p>
<p>View: View can be your Aspx page in your web applications or any user controls/Interface for the end user.<br />
Model: Contains all the business logic.</p>
<p>Presenter: Works as the intermediate agent for Model and View. It binds the view with the model. See the diagram below. </p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/mvp1.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/mvp1.gif?w=300&#038;h=18" alt="" title="MVP1" width="300" height="18" class="alignleft size-medium wp-image-189" /></a></p>
<p>In the following diagram a couple of blocks are added which are interfaces through which the presenter will interact.</p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/mvp2.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/mvp2.gif?w=300&#038;h=106" alt="" title="MVP2" width="300" height="106" class="alignleft size-medium wp-image-190" /></a></p>
<p>Let&#8217;s take a simple example of how to implement it.</p>
<p>Create a web application project in your Visual Studio. Now add 3 more classes named View.cs, Presenter.cs and Model.cs and add the interfaces IView and IModel.</p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/mvp3.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/mvp3.gif?w=614" alt="" title="MVP3"   class="alignleft size-full wp-image-191" /></a></p>
<p>Start with the aspx page (View). Add a label, a button and a TextBox.</p>
<p>Now we won&#8217;t write anything in aspx.cs file. First write the code in IView.</p>
<p>namespace WebApplication1<br />
{<br />
    public interface IView<br />
    {<br />
        String Label { get; set; }<br />
        String TextBox { get; set; }<br />
    }<br />
}</p>
<p>Similarly write some code in IModel.cs</p>
<p>namespace WebApplication1<br />
{<br />
    public interface IModel<br />
    {<br />
       List setInfo();<br />
    }<br />
}</p>
<p>Now Model.cs. Let&#8217;s say we send the information about the Label and TextBox from Model.</p>
<p>namespace WebApplication1<br />
{<br />
    class Model : IModel<br />
    {<br />
        public List setInfo()<br />
        {<br />
            List l = new List();<br />
            l.Add(&#8220;Enter Name:&#8221;);<br />
            l.Add(&#8220;Use capital letter only&#8221;);<br />
            return l;<br />
        }<br />
    }<br />
}</p>
<p>Now we need to write some code in the presenter so that the View and Model can communicate with each other. It&#8217;ll go like this:</p>
<p>namespace WebApplication1<br />
{<br />
    public class Presenter<br />
    {<br />
        IView _pView;<br />
        IModel _pModel;<br />
        public Presenter(IView PView, IModel PModel)<br />
        {<br />
            _pView = PView;<br />
            _pModel = PModel;\<br />
        }<br />
        public void BindModalView()<br />
        {<br />
            List ls = _pModel.setInfo();<br />
            _pView.Label = ls[0];<br />
            _pView.TextBox = ls[1];<br />
        }<br />
    }<br />
}</p>
<p>Finally go to aspx.cs and Implement the IView. </p>
<p>public partial class _Default : System.Web.UI.Page, IView<br />
    {<br />
        protected void Page_Load(object sender, EventArgs e)<br />
        { </p>
<p>        } </p>
<p>        #region IView Members </p>
<p>        public string Label<br />
        {<br />
            get<br />
            {<br />
                return Label1.Text;<br />
            }<br />
            set<br />
            {<br />
                Label1.Text = value;<br />
            }<br />
        } </p>
<p>        public string TextBox<br />
        {<br />
            get<br />
            {<br />
                return TextBox1.Text;<br />
            }<br />
            set<br />
            {<br />
                TextBox1.Text = value;<br />
            }<br />
        } </p>
<p>        #endregion</p>
<p>Add an event for the button and write the code to get the data from Model through presenter and then bind it to the View. In the constructor of Presenter we passed &#8220;this&#8221; which means reference of the same aspx page.</p>
<p>protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
      Presenter p = new Presenter(this, new WebApplication1.Model());<br />
      p.BindModalView();<br />
}</p>
<p>And you have implemented a small application with MVP pattern.</p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=188&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2011/06/09/mvp-design-pattern-of-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/mvp1.gif?w=300" medium="image">
			<media:title type="html">MVP1</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/mvp2.gif?w=300" medium="image">
			<media:title type="html">MVP2</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/mvp3.gif" medium="image">
			<media:title type="html">MVP3</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows Communication Foundation (WCF)</title>
		<link>http://shyleshgov.wordpress.com/2011/06/07/windows-communication-foundation-wcf/</link>
		<comments>http://shyleshgov.wordpress.com/2011/06/07/windows-communication-foundation-wcf/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 08:51:26 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=179</guid>
		<description><![CDATA[Windows Communication Foundation (WCF) is a dedicated communication framework provided by Microsoft. WCF is a part of .NET 3.0. Creating and Consuming a Sample WCF Service: Three major steps are involved in the creation and consumtion of the WCF services. Those are: 1. Create the Service.(Creating) 2. Binding an address to the service and host [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=179&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Windows Communication Foundation (WCF) is a dedicated communication framework provided by Microsoft. WCF is a part of .NET 3.0.</p>
<p><strong>Creating and Consuming a Sample WCF Service: </strong><br />
Three major steps are involved in the creation and consumtion of the WCF services. Those are:<br />
1. Create the Service.(Creating)<br />
2. Binding an address to the service and host the Service. (Hosting)<br />
3. Consuming the Service.(Consuming)</p>
<p>Step 1: Creating the Service </p>
<p>In WCF, all services are exposed as contracts. A contract is a neutral way of describing what the service does. Mainly we have four types of contracts:<br />
Service Contract</p>
<p>This contract describes all the available operations that a client can perform on the service.</p>
<p>.Net uses &#8220;System.ServiceModel&#8221; Name space to work with WCF services. </p>
<p>ServiceContract attribute is used to define the service contract. We can apply this attribute on class or interface. ServiceContract attribute exposes a CLR interface (or a class) as a WCF contract.</p>
<p>OperationContract attribute, is used to indicate explicitly which method is used to expose as part of WCF contract. We can apply OperationContract attribute only on methods, not on properties or indexers.  </p>
<p>[ServiceContract] applies at the class or interface level.<br />
[OperatiContract] applies at the method level. </p>
<p>Data Contract</p>
<p>This contract defines the data types that are passed into and out of the service.</p>
<p>[DataContract] attribute is used at the custom data type definition level, i.e. at class or structure level.<br />
[DataMember] attribute is used for fields, properties, and events.</p>
<p>Fault Contract </p>
<p>This contract describes about the error raised by the services. </p>
<p>[FaultContract(&lt;&gt;)] attribute is used for defining the fault contracts.</p>
<p>Message Contracts</p>
<p>This contract provides the direct control over the SOAP message structure. This is useful in inter-operability cases and when there is an existing message format you have to comply with.</p>
<p>[MessageContract] attribute is used to define a type as a Message type.<br />
[MessageHeader] attribute is used for those members of the type we want to make into SOAP headers<br />
[MessageBodyMember] attribute is used for those members we want to make into parts of the SOAP body of the message. </p>
<p><strong>Sample Service Creation </strong></p>
<p>[ServiceContract] </p>
<p>          public interface IFirstWCFService </p>
<p>                    { </p>
<p>                   [OperationContract] </p>
<p>                   int Add(int x, int y); </p>
<p>                   [OperationContract] </p>
<p>                   string Hello(string strName); </p>
<p>                  int Multiplication(int x, int y); </p>
<p>                   }<br />
Here &#8220;IFirstWCFService&#8221; is a service exposed by using the servicecontract attribute. This service exposes two methods &#8220;Add&#8221;,&#8221;Hello&#8221; by using the [OperationContract] attribute. The method &#8220;Multiplication&#8221; is not exposed by using the [OperationContract] attribute. So it wnt be avlible in the WCF service. </p>
<p>public class FrtWCFService : IFirstWCFService </p>
<p>    { </p>
<p>        public int Add(int x, int y) </p>
<p>        { </p>
<p>            return x + y; </p>
<p>        } </p>
<p>        public string Hello(string strName) </p>
<p>        { </p>
<p>            return &#8220;WCF program  : &#8221; + strName; </p>
<p>        } </p>
<p>        public int Multiplication(int x, int y) </p>
<p>        { </p>
<p>            return x * y; </p>
<p>        } </p>
<p>    }<br />
&#8220;FrtWCFService&#8221; is a class,which implements the interface &#8220;IFirstWCFService&#8221;. This class definse the functionality of methods exposed as services.  </p>
<p>STEP 2:  Binding and Hosting </p>
<p>Each service has an end point. Clients communicates with this end points only. End point describes 3 things : </p>
<p>1. Address<br />
2. Binding type<br />
3. Contract Name (which was defined in STEP 1)</p>
<p>Address </p>
<p>Every service must be associated with a unique address. Address mainly contains the following  two key factors :<br />
Transport protocal used to communicate between the client proxy and service.</p>
<p>WCF supports the following transport machinisams:</p>
<p>HTTP   (ex : http://  or https:// )<br />
TCP     (ex :  net.tcp :// )<br />
Peer network   (ex: net.p2p://)<br />
IPC (Inter-Process Communication over named pipes) (ex: net.pipe://)<br />
MSMQ  (ex: net.msmq://)</p>
<p>Location of the service.</p>
<p>Location of the service describes the targeted machine (where service is hosted) complete name (or) path  and optionally port / pipe /queue name.<br />
Example :   localhost:8081<br />
Here local host is the target machine name.<br />
8081 is the optional port number.<br />
Example 2:  localhost<br />
This is with out optional parameter. </p>
<p>Hosting:<br />
Every service must be hosted in a host process. Hosting can be done by using the </p>
<p>IIS<br />
Windows Activation Service (WAS)<br />
Self hosting </p>
<p>IIS Hosting </p>
<p>IIS hosting is the same as hosting the traditional web service hosting. Create a virtual directory and supply a .svc file.<br />
In Vs2008 select a project type: &#8220;WCF Service Application&#8221;. </p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/projecttype.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/projecttype.gif?w=300&#038;h=197" alt="" title="ProjectType" width="300" height="197" class="alignleft size-medium wp-image-180" /></a></p>
<p>In the solution explorer, under the App_code folder you can find the two files: &#8220;IService.cs&#8221; and &#8220;Service.cs&#8221;.<br />
&#8220;IService.cs&#8221; class file defines the contracts. &#8220;Service.cs&#8221; implements the contracts defined in the &#8220;IService.cs&#8221;. Contracts defined in the &#8220;IService.cs&#8221; are exposed in the service.    </p>
<p>In this one , end point node specifies the : address, binding type, contract (this is the name of the class that defines the contracts.)<br />
Another end point node endpoint address=&#8221;mex&#8221; specify about the Metadata end point for the service.<br />
Now host this serivce by creating the virtual directory and browse the *.SVC file: </p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/iishosting1.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/iishosting1.gif?w=614" alt="" title="IISHosting" class="alignleft size-full wp-image-193" /></a></p>
<p>STEP 3: Consuming the Service </p>
<p>With WCF, the client always communicates with the proxy only. Client never directly communicates with the services, even though the service is located on the same machine. Client communicates with the proxy; proxy forwards the call to the service.  Proxy exposes the same functionalities as Service exposed. </p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/serviceboundaries1.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/serviceboundaries1.gif?w=300&#038;h=89" alt="" title="ServiceBoundaries" width="300" height="89" class="alignleft size-medium wp-image-194" /></a></p>
<p>Consuming WCF Service Hosted by IIS/WAS </p>
<p>Consuming WCF service is a very similar way of consuming a web service by using the proxy. To consume the service, in the solution explorer click on &#8220;Add service Reference&#8221; and add the service created in the STEP1.</p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/addserviceref1.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/addserviceref1.gif?w=238&#038;h=300" alt="" title="AddServiceRef" width="238" height="300" class="alignleft size-medium wp-image-195" /></a></p>
<p><a href="http://shyleshgov.files.wordpress.com/2011/06/addserviceref_2.gif"><img src="http://shyleshgov.files.wordpress.com/2011/06/addserviceref_2.gif?w=300&#038;h=248" alt="" title="AddServiceRef_2" width="300" height="248" class="alignleft size-medium wp-image-196" /></a></p>
<p>A service reference is created under the service reference folder. Use this proxy class to consume the WCF service as we are doing with web services. </p>
<p>ServiceReference1.FirstWCFServiceClient obj = new                  </p>
<p>             UsingWCFService.ServiceReference1.FirstWCFServiceClient(); </p>
<p>Console.WriteLine(obj.Add(2, 3).ToString()); </p>
<p>obj.Close(); </p>
<p>Alternatively: We can create  the proxy class by using the following command </p>
<p>svcutil.exe [WCFService Address] </p>
<p>This generates a service proxy class, just include this class in to the solution and consume the service. </p>
<p>Consuming by creating the channel factory: </p>
<p>We can consume the service by creating the channel factory manually. While creating the channel, we have to provide the same binding type and end point address where the service is hosted. </p>
<p>IFirstWCFService chnl = new ChannelFactory </p>
<p>(new BasicHttpBinding(), new EndpointAddress(&#8220;http://localhost:8080/MYFirstWCFService&#8221;)).CreateChannel();<br />
Here IFirstWCFService is the service contract interface, that is exposed. </p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/179/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/179/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/179/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=179&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2011/06/07/windows-communication-foundation-wcf/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/projecttype.gif?w=300" medium="image">
			<media:title type="html">ProjectType</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/iishosting1.gif" medium="image">
			<media:title type="html">IISHosting</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/serviceboundaries1.gif?w=300" medium="image">
			<media:title type="html">ServiceBoundaries</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/addserviceref1.gif?w=238" medium="image">
			<media:title type="html">AddServiceRef</media:title>
		</media:content>

		<media:content url="http://shyleshgov.files.wordpress.com/2011/06/addserviceref_2.gif?w=300" medium="image">
			<media:title type="html">AddServiceRef_2</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 in review</title>
		<link>http://shyleshgov.wordpress.com/2011/01/03/2010-in-review/</link>
		<comments>http://shyleshgov.wordpress.com/2011/01/03/2010-in-review/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 06:17:58 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=175</guid>
		<description><![CDATA[The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health: The Blog-Health-o-Meter™ reads Minty-Fresh™. Crunchy numbers The Leaning Tower of Pisa has 296 steps to reach the top. This blog was viewed about 1,200 times in 2010. If those were [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=175&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[
<p>The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here&#8217;s a high level summary of its overall blog health:</p>
<p align="center"><img style="border:1px solid #ddd;background:#f5f5f5;padding:20px;" src="http://s0.wp.com/i/annual-recap/meter-healthy.gif" width="250" height="183" alt="Healthy blog!"></p>
<p align="center">The <em>Blog-Health-o-Meter™</em> reads Minty-Fresh™.</p>
<h2>Crunchy numbers</h2>
<p>The Leaning Tower of Pisa has 296 steps to reach the top.  This blog was viewed about <strong>1,200</strong> times in 2010.  If those were steps, it would have climbed the Leaning Tower of Pisa 4 times</p>
<p>
<p>In 2010, there were <strong>12</strong> new posts, growing the total archive of this blog to 21 posts. There were <strong>9</strong> pictures uploaded, taking up a total of 498kb. That&#8217;s about a picture per month.</p>
<p>The busiest day of the year was August 19th with <strong>28</strong> views. The most popular post that day was <a style="color:#08c;" href="http://shyleshgov.wordpress.com/2010/08/19/printing-a-datagrid/">Printing a datagrid</a>.</p>
<p></p>
<h2>Where did they come from?</h2>
<p>The top referring sites in 2010 were <strong>alducente.wordpress.com</strong>, <strong>bigextracash.com</strong>, <strong>google.co.in</strong>, <strong>sadi02.wordpress.com</strong>, and <strong>me2u-paypal.com</strong>.</p>
<p>Some visitors came searching, mostly for <strong>dotnet changing wcf endpoint address</strong>, <strong>zameb wordpress</strong>, <strong>silverlight initparams service url</strong>, <strong>wcf endpoint dynamically</strong>, and <strong>dotnet 2010 command stored procedure</strong>.</p>
<div style="clear:both;"></div>
<h2>Attractions in 2010</h2>
<p>These are the posts and pages that got the most views in 2010.</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">1</div>
<p>					<a style="margin-right:10px;" href="http://shyleshgov.wordpress.com/2010/08/19/printing-a-datagrid/">Printing a datagrid</a> <span style="color:#999;font-size:8pt;">August 2010</span>											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">2</div>
<p>					<a style="margin-right:10px;" href="http://shyleshgov.wordpress.com/2010/06/05/dynamically-changing-urlendpoint-for-wcf-service-in-silverlight/">Dynamically changing url/endpoint for WCF service in Silverlight</a> <span style="color:#999;font-size:8pt;">June 2010</span>											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">3</div>
<p>					<a style="margin-right:10px;" href="http://shyleshgov.wordpress.com/2009/10/23/web-services/">Web Services</a> <span style="color:#999;font-size:8pt;">October 2009</span><br />4 comments											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">4</div>
<p>					<a style="margin-right:10px;" href="http://shyleshgov.wordpress.com/about/">About me</a> <span style="color:#999;font-size:8pt;">October 2009</span>											</p>
<div style="clear:left;float:left;font-size:24pt;line-height:1em;margin:-5px 10px 20px 0;">5</div>
<p>					<a style="margin-right:10px;" href="http://shyleshgov.wordpress.com/2009/11/26/state-management-in-asp-net-view-state-and-session-state/">State Management in ASP.NET &#8211; View State and Session State</a> <span style="color:#999;font-size:8pt;">November 2009</span>											</p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/general/'>General</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/175/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/175/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/175/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=175&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2011/01/03/2010-in-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>

		<media:content url="http://s0.wp.com/i/annual-recap/meter-healthy.gif" medium="image">
			<media:title type="html">Healthy blog!</media:title>
		</media:content>
	</item>
		<item>
		<title>FileUpload issue with Update Panel</title>
		<link>http://shyleshgov.wordpress.com/2010/09/16/fileupload-and-update-panel/</link>
		<comments>http://shyleshgov.wordpress.com/2010/09/16/fileupload-and-update-panel/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 06:04:17 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[File upload issue with update panel]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=169</guid>
		<description><![CDATA[Hi all, In one of my projects, I have coded like this. code behind&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62; protected void Button2_Click(object sender, EventArgs e) { if (fupLogo.HasFile) { string fileFormat = fupLogo.PostedFile.ContentType; Label1.Text = fupLogo.PostedFile.ContentType; if (string.Compare(fileFormat, "image/jpeg", true) == 0 &#124;&#124; string.Compare(fileFormat, "image/png", true) == 0 &#124;&#124; string.Compare(fileFormat, "image/gif", true) == 0) { Label1.Text += "file format supported"; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=169&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>In one of my projects, I have coded like this.</p>
<p>code behind&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</p>
<p><code>protected void Button2_Click(object sender, EventArgs e)<br />
{<br />
if (fupLogo.HasFile)<br />
{<br />
string fileFormat = fupLogo.PostedFile.ContentType;<br />
Label1.Text = fupLogo.PostedFile.ContentType;<br />
if (string.Compare(fileFormat, "image/jpeg", true) == 0 ||<br />
string.Compare(fileFormat, "image/png", true) == 0 ||<br />
string.Compare(fileFormat, "image/gif", true) == 0)<br />
{<br />
Label1.Text += "file format supported<br />";<br />
}<br />
else<br />
{<br />
Label1.Text +="file format not supported<br />";<br />
}<br />
}<br />
else<br />
{<br />
Label1.Text += "file not exist<br />";<br />
}<br />
}</code></p>
<p><code>protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
fupLogo.Visible = true;<br />
Button2.Visible=true;<br />
}</code></p>
<p>this behaves like on page load it shows a button then the onclick of the<br />
button it shows a fileupload and upload button</p>
<p><strong>Expected:</strong> when i cliks upload button after selecting any file<br />
ouput must be &#8220;file format supported/not suported&#8221;<br />
<strong><br />
Actual:</strong> but the output is &#8220;file not exist&#8221;.</p>
<p>As a solution I just found these,<br />
Use style=&#8221;display:none&#8221; instead of Visible=&#8221;False&#8221;. In this case PostBackTrigger for Button2 works correctly.<br />
<strong>Example:</strong><br />
<em>..aspx file</em><br />
<code>asp:FileUpload ID="fupLogo" runat="server" style="display:none"<br />
asp:Button ID="Button2" runat="server" Text="Upload"<br />
OnClick="Button2_Click" style="display:none" </code></p>
<p><em>..cs file</em><br />
<code>protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
fupLogo.Style.Remove("display");<br />
Button2.Style.Remove("display");<br />
}</code></p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a> Tagged: <a href='http://shyleshgov.wordpress.com/tag/file-upload-issue-with-update-panel/'>File upload issue with update panel</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=169&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/09/16/fileupload-and-update-panel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Smooth horizontal page scrolling with ASP.NET Button and JQuery</title>
		<link>http://shyleshgov.wordpress.com/2010/09/09/smooth-horizontal-page-scrolling-with-asp-net-button-and-jquery/</link>
		<comments>http://shyleshgov.wordpress.com/2010/09/09/smooth-horizontal-page-scrolling-with-asp-net-button-and-jquery/#comments</comments>
		<pubDate>Thu, 09 Sep 2010 10:57:06 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=160</guid>
		<description><![CDATA[Hi all, In one of my projects I just had to come over a requirement where I have a search page with a search button and a gridview control which displays the search results. The search criteria list is a long one so, when the user clicks the search button, he/she may not even know [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=160&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi all,</p>
<p>In one of my projects I just had to come over a requirement where I have a search page with a search button and a gridview control which displays the search results. The search criteria list is a long one so, when the user clicks the search button, he/she may not even know that results have been displayed or not unless he/she scrolls down the page. In this example, I have the code for displaying the search results in button&#8217;s click event. So when the user clicks the button, the grid will get filled with the results and also a smooth scrolling is made to the position where the grid is placed.</p>
<p>For the above, you have just include these JQuery files.<br />
<a href="http://code.jquery.com/jquery.min.js">http://code.jquery.com/jquery.min.js</a><br />
<a href="http://gsgd.co.uk/sandbox/jquery/easing/">http://gsgd.co.uk/sandbox/jquery/easing/</a></p>
<p>After including these files, just put the following code in the Page_Load<br />
<code>btnSearch.Attributes.Add("onclick", " $('html, body').stop().animate({scrollTop: $('#divCandidate').offset().top}, 5000, 'easeInOutExpo');;return true;");</code></p>
<p>In the above code &#8220;divCandidate&#8221; is the div in which the gridview is residing. 5000 is the scrolling time interval.</p>
<p>Also, make sure the criteria list (most probably, a table containing some controls) and the gridview are resided in an update panel.</p>
<p>Happy Scrolling!!</p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=160&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/09/09/smooth-horizontal-page-scrolling-with-asp-net-button-and-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>A JScript/VBScript Regex Lookahead Bug</title>
		<link>http://shyleshgov.wordpress.com/2010/09/06/a-jscriptvbscript-regex-lookahead-bug/</link>
		<comments>http://shyleshgov.wordpress.com/2010/09/06/a-jscriptvbscript-regex-lookahead-bug/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 09:36:22 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=155</guid>
		<description><![CDATA[Here&#8217;s one of the oddest and most significant regex bugs in Internet Explorer. It can appear when using optional elision within lookahead (e.g., via ?, *, {0,n}, or (.&#124;); but not +, interval quantifiers starting from one or higher, or alternation without a zero-length option). An example in JavaScript: /(?=a?b)ab/.test("ab"); // Should return true, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=155&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s one of the oddest and most significant regex bugs in Internet Explorer. It can appear when using optional elision within lookahead (e.g., via ?, *, {0,n}, or (.|); but not +, interval quantifiers starting from one or higher, or alternation without a zero-length option). An example in JavaScript:</p>
<p><code>/(?=a?b)ab/.test("ab");<br />
// Should return true, but IE 5.5 – 8b1 return false</code></p>
<p><code>/(?=a?b)ab/.test("abc");<br />
// Correctly returns true (even in IE), although the<br />
// added "c" does not take part in the match</code></p>
<p>Thanks to a blog post by <a href="http://blog.stevenlevithan.com/archives/regex-lookahead-bug">Steve</a> that describes the bug with a password-complexity regex. However, the bug description there is incomplete and subtly incorrect, as shown by the above, reduced test case. </p>
<p>Fortunately, since the bug is predictable, it&#8217;s usually possible to work around. For example, you can avoid the bug with the password regex in Michael&#8217;s post (/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$/) by writing it as /^(?=.{8,15}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*/ (the .{8,15}$ lookahead must come first here). The important thing is to be aware of the issue, because it can easily introduce latent and difficult to diagnose bugs into your code. Just remember that it shows up with variable-length lookahead. If you&#8217;re using such patterns, test the hell out of them in IE.</p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/155/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/155/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/155/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=155&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/09/06/a-jscriptvbscript-regex-lookahead-bug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Passing array to stored procedure</title>
		<link>http://shyleshgov.wordpress.com/2010/09/01/passing-array-to-stored-procedure/</link>
		<comments>http://shyleshgov.wordpress.com/2010/09/01/passing-array-to-stored-procedure/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 13:03:21 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=148</guid>
		<description><![CDATA[Consider the following simple method for defining the stored procedure using dynamic SQL. The array parameter is defined simply as a string and the input will be expected to be comma-delimited. By forming the sql dyanmically with the input string, we can query against the values in the array by using the IN command. Stored [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=148&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Consider the following simple method for defining the stored procedure using dynamic SQL. The array parameter is defined simply as a string and the input will be expected to be comma-delimited. By forming the sql dyanmically with the input string, we can query against the values in the array by using the IN command.</p>
<p><strong>Stored Procedure</strong><br />
CREATE PROCEDURE [dbo].[GetData]<br />
 @MyCodes as varchar(500) = &#8221;, &#8212; comma delimited list of codes, ie: &#8221;&#8217;ABC&#8221;, &#8221;DEF&#8221;, &#8221;GHI&#8221;&#8217;<br />
AS<br />
BEGIN<br />
   DECLARE @query as nvarchar(500)</p>
<p>   set @query = &#8216;SELECT * FROM DATA WHERE Code IN (@p_MyCodes)&#8217;</p>
<p>   exec SP_EXECUTESQL @query,<br />
                                                N&#8217;@p_MyCodes varchar(500)&#8217;,<br />
                                                @p_MyCodes = @MyCodes<br />
END</p>
<p>The above stored procedure definition will accept a comma-delimited string, which we process as an array using the SQL IN command. Note, we had to use dyanmic SQL to properly form the query (which involves expanding the comma-delimited string).</p>
<p>Next, we need to define the method to pass the data and execute the stored procedure from C# .NET.</p>
<p>The first step is to convert our array of data into a comma-delimited string, which is what the stored procedure expects to receive. Depending on your data type, this code may vary. For this example, we are using a .NET collection.</p>
<p>string myCodes = string.Empty; // Initialize a string to hold the comma-delimited data as empty</p>
<p><code>foreach (MyItem item in MyCollection)<br />
{<br />
   if (myCodes.Length &gt; 0)<br />
   {<br />
      myCodes += ", "; // Add a comma if data already exists<br />
   }<br />
</code><br />
   <code>myCodes += "'" + item.Name + "'";<br />
}</code></p>
<p>The code above will create a string in the following format:<br />
&#8216;Blue&#8217;,'Green&#8217;,'Red&#8217;</p>
<p>Now that the collection has been converted to a string, we can pass the value as a parameter to the stored procedure by using the following code:</p>
<p><code>using System;<br />
using System.Data;<br />
using System.Data.SqlClient;</code></p>
<p><code>SqlConnection MyConnection = null;<br />
SqlDataReader MyReader = null;</code></p>
<p><code>try<br />
{<br />
   // Create the SQL connection.<br />
   MyConnection = new SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI"))<br />
   MyConnection.Open();</p>
<p>  <code> // Create the stored procedure command.<br />
   SqlCommand MyCommand = new SqlCommand("GetData", MyConnection);</code></p>
<p> <code>  // Set the command type property.<br />
   MyCommand.CommandType = CommandType.StoredProcedure;</code><br />
<code><br />
   // Pass the string (array) into the stored procedure.<br />
   MyCommand.Parameters.Add(new SqlParameter("@MyCodes", myCodes));</code></p>
<p>  <code> // Execute the command<br />
   MyReader = MyCommand.ExecuteReader();</code></p>
<p>   // ...<br />
}</code><br />
<code>catch (Exception excep)<br />
{<br />
}</code><br />
<code>finally<br />
{<br />
   if (MyReader != null)<br />
   {<br />
      MyReader.Close();<br />
      MyReader.Dispose();<br />
   }</p>
<p>  <code> if (MyConnection != null)<br />
   {<br />
      MyConnection.Close();<br />
      MyConnection.Dispose();<br />
   }</code><br />
}</code></p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=148&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/09/01/passing-array-to-stored-procedure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Tuples in .NET Framework 4.0</title>
		<link>http://shyleshgov.wordpress.com/2010/08/25/tuples-in-net-framework-4-0/</link>
		<comments>http://shyleshgov.wordpress.com/2010/08/25/tuples-in-net-framework-4-0/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 12:16:06 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[.Net Framework]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=143</guid>
		<description><![CDATA[Another new feature in the .NET 4 Framework is support for tuples,which are similar to anonymous classes that you can create on the fly. A tuple is a data structure used in many functional and dynamic languages, such as F# and Iron Python. By providing common tuple types in the BCL, we are helping to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=143&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Another new feature in the .NET 4 Framework is support for tuples,which are similar to anonymous classes that you can create on the fly. A tuple is a data structure used in many functional and dynamic languages, such as F# and Iron Python. By providing common tuple types in the BCL, we are helping to better facilitate language interoperability. Many programmers find tuples to be convenient, particularly for returning multiple values from methods.</p>
<p>Here is a code which uses a function that returns two values.</p>
<p>	<code>class Program<br />
	{<br />
	    static void Main(string[] args)<br />
	    {<br />
	        //Getting the values from the Tuple Function<br />
	        Tuple details = GetDetails();<br />
	        Console.WriteLine("FirstName : {0}, LastName :{1}", details.Item1, details.Item2);<br />
	        Console.Read();<br />
	    }</code><br />
	    //Tuple function, which reads two values from<br />
	    //user and returns to the main<br />
	    <code>static Tuple GetDetails()<br />
	    {<br />
	        Console.Write("Enter First Name:");<br />
	        string _firstName = Console.ReadLine();<br />
	        Console.Write("Enter Last Name:");<br />
	        string _lastName = Console.ReadLine();<br />
	        return new Tuple(_firstName, _lastName);<br />
	    }<br />
	}</code></p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/net-framework/'>.Net Framework</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/143/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/143/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/143/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=143&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/08/25/tuples-in-net-framework-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Printing a datagrid</title>
		<link>http://shyleshgov.wordpress.com/2010/08/19/printing-a-datagrid/</link>
		<comments>http://shyleshgov.wordpress.com/2010/08/19/printing-a-datagrid/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 06:15:01 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=138</guid>
		<description><![CDATA[Hi, Here I would like to share the code to print a datagrid in ASP.NET Put the given code in tag function CallPrint(strid) { var prtContent = document.getElementById(strid); var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0'); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); //prtContent.innerHTML = strOldOne; } Put your datagrid in a tag. Here I use a div [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=138&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Here I would like to share the code to print a datagrid in ASP.NET</p>
<p>Put the given code in  tag<br />
<code><br />
    function CallPrint(strid) {<br />
        var prtContent = document.getElementById(strid);<br />
        var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');<br />
        WinPrint.document.write(prtContent.innerHTML);<br />
        WinPrint.document.close();<br />
        WinPrint.focus();<br />
        WinPrint.print();<br />
        WinPrint.close();<br />
        //prtContent.innerHTML = strOldOne;<br />
    }<br />
</code></p>
<p>Put your datagrid in a
<div> tag. Here I use a div named &#8220;divPrint&#8221;.</p>
<p>Put this code in your print button</p>
<p><code>OnClientClick="javascript:CallPrint('divPrint');"</code></p>
<p>or</p>
<p><code>OnClick="javascript:CallPrint('divPrint');"</code></p>
<p> <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Coding !!</p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/138/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/138/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/138/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=138&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/08/19/printing-a-datagrid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
		<item>
		<title>Browser back button shows user pages after logging out</title>
		<link>http://shyleshgov.wordpress.com/2010/08/19/browser-back-button-shows-user-pages-after-logging-out/</link>
		<comments>http://shyleshgov.wordpress.com/2010/08/19/browser-back-button-shows-user-pages-after-logging-out/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 05:51:00 +0000</pubDate>
		<dc:creator>Shylesh Govindan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>

		<guid isPermaLink="false">http://shyleshgov.wordpress.com/?p=133</guid>
		<description><![CDATA[Hi friends, Session clearing is a very important issue after the user has logged out from his dashboard. After his/her logging out, the pages meant for the user should not be displayed. When we try to access these through links login page or any other respective pages are displayed. For the same we remove the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=133&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi friends,</p>
<p>Session clearing is a very important issue after the user has logged out from his dashboard. After his/her logging out, the pages meant for the user should not be displayed. When we try to access these through links login page or any other respective pages are displayed. For the same we remove the sessions for the user when the user logs out.</p>
<p>Session.RemoveAll();</p>
<p>Above code will remove all the sessions created for the user. After this process when we try to access the user pages through URLs it will show the user has not logged in. </p>
<p>I would like to discuss a scenario where user logs out and we hits the browser back button, even if the sessions are cleared it shows the previous page, i.e, the user page. Is there a solution for this? Of course !!</p>
<p>Put this code in the Page_Load of the user page in addition to the session clearing code in the log out button.</p>
<p>   <code>     Response.Buffer = true;<br />
        Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);<br />
        Response.Expires = -1500;<br />
        Response.CacheControl = "no-cache";</code></p>
<p>        <code>Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));<br />
        Response.Cache.SetCacheability(HttpCacheability.NoCache);<br />
        Response.Cache.SetNoStore();</code></p>
<br />Filed under: <a href='http://shyleshgov.wordpress.com/category/asp-net/'>ASP.NET</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/shyleshgov.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/shyleshgov.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/shyleshgov.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=shyleshgov.wordpress.com&amp;blog=8851937&amp;post=133&amp;subd=shyleshgov&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://shyleshgov.wordpress.com/2010/08/19/browser-back-button-shows-user-pages-after-logging-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/0da175603b5ad9001c7d188adc859fbc?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Shylesh</media:title>
		</media:content>
	</item>
	</channel>
</rss>
