<?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/"
	>

<channel>
	<title>.toString()</title>
	<atom:link href="http://www.dottostring.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dottostring.com</link>
	<description>Programming is our passion</description>
	<lastBuildDate>Sun, 04 Oct 2009 15:57:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Django deployment on Amazon EC2 &#8211; Step by step tutorial</title>
		<link>http://www.dottostring.com/2009/10/django-deployment-on-amazon-ec2-step-by-step-tutorial/</link>
		<comments>http://www.dottostring.com/2009/10/django-deployment-on-amazon-ec2-step-by-step-tutorial/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 15:57:48 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=382</guid>
		<description><![CDATA[Making EC2 Tools environment:

Download and the command line tools from http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&#38;categoryID=88 and extract at some place like: C:\ec2-api-tools-1.3-41620
Login into your amazon EC2 account. Goto:
Your Account -&#62; Security Credentials -&#62; x.509 Certificates
make one and download to some place like C:\ec2
Make sure that you have latest version of JRE installed on your local machine. Now use the [...]]]></description>
			<content:encoded><![CDATA[<h2>Making EC2 Tools environment:</h2>
<ol>
<li>Download and the command line tools from <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&amp;categoryID=88" target="_blank">http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&amp;categoryID=88</a> and extract at some place like: C:\ec2-api-tools-1.3-41620</li>
<li>Login into your amazon EC2 account. Goto:<br />
Your Account -&gt; Security Credentials -&gt; x.509 Certificates<br />
make one and download to some place like C:\ec2</li>
<li>Make sure that you have latest version of JRE installed on your local machine. Now use the following commands to set environment variables, (CHANGE THE PATHS TO YOUR PATHS):<br />
<code>set JAVA_HOME="C:\Program Files\Java\jdk1.6.0_11"<br />
set EC2_HOME=C:\ec2-api-tools-1.3-41620<br />
set PATH=%PATH%;%EC2_HOME%\bin<br />
set EC2_PRIVATE_KEY=c:\ec2\pk-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem<br />
set EC2_CERT=c:\ec2\cert-HKZYKTAIG2ECMXYIBH3HXV4ZBZQ55CLO.pem</code></li>
</ol>
<p>Now we have our local machine ready to use EC2 commands.</p>
<h2>Running and connecting to the instance</h2>
<ol>
<li>Get a list of available amazon AMIs using this command<br />
<code>ec2-describe-images -o self -o amazon | grep fedora</code> <br />
We have applied the fedora filter as we want to use it. There is an apache-mysql fedora core4 AMI available as ec2-public-images/fedora-core4-apache-mysql.manifest.xml. We will be using this AMI. Note down its id, which is in this case: ami-25b6534c</li>
<li>Now we will be downloading our private RSA key to be used with this AMI. Run the following command in command prompt:<br />
<code>ec2-add-keypair gsg-keypair<br />
</code>and save everything between these lines including these lines as &#8220;id_rsa-gsg-keypair&#8221;:<br />
&#8220;&#8212;&#8211;BEGIN RSA PRIVATE KEY&#8212;&#8211;&#8221;<br />
&#8220;&#8212;&#8211;END RSA PRIVATE KEY&#8212;&#8211;&#8221;   <br />
We want to use putty to communicate with this AMI. Our private key needs to be converted into putty format. Download puttygen.exe from <a href="http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe " target="_blank">http://the.earth.li/~sgtatham/putty/latest/x86/puttygen.exe </a>open puttygen.exe, load id_rsa-gsg-keypair and save private key</li>
<li>Run the public AMI instance using this command:<br />
<code>ec2-run-instances ami-25b6534c -k gsg-keypair<br />
</code>NOTE DOWN THE ID OF THE INSTANCE </li>
<li>You can use this command to check the status of you instance. Note down the server address of the instance:<br />
<code>ec2-describe-instances i-548****<br />
</code>(Replace i-548**** with you instance id)</li>
<li>Now we need to open port 22 (for ssh) and port 80 (for http) on this instance. Run the following commands in command prompt.<br />
<code>ec2-authorize default -p 22<br />
ec2-authorize default -p 80</code></li>
<li>Enter the server address noted down in step 4 to your browser. You should see a default Fedora Core 4 Apache welcome page.</li>
<li>Open putty; goto<br />
Connection -&gt; SSH -&gt; Auth<br />
browse for your private key you made using puttygen.                            </p>
<p>Enter the sever address from step 4 to connect and use the username &#8216;root&#8217; to login. </li>
<li>Once successfully connected, you can use this instance like any other Linux server.</li>
</ol>
<h2>Configuring Server, Apache and mode_python</h2>
<ol>
<li><a href="http://yum.baseurl.org/" target="_blank">Yum</a> is already installed on this instance but it needs to be configured. Open the file <em>/etc/yum.repos.d/fedora.repo</em> and uncomment the <em>baseurl</em> line. Also change the url to http://archives.fedoraproject.org/pub/archive/fedora/linux/*****<br />
Do the same with <br />
<em> /etc/yum.repos.d/fedora-updates.repo <span style="font-style: normal;">and</span><br />
/etc/yum.repos.d/fedora-extras.repo</em></li>
<li>Update the list:<br />
<code>yum check-update</code></li>
<li>Use following  commands to install some packages using yum:<br />
<code>yum install gcc<br />
yum install httpd-devel<br />
yum install python-devel</code></li>
<li>Now install mod_python using following commands:<br />
cd /tmp<br />
wget http://download.filehat.com/apache/httpd/modpython/mod_python-3.3.1.tgz<br />
tar xvfz mod_python-3.3.1.tgz<br />
cd mod_python-3.3.1<br />
./configure<br />
make<br />
make install</li>
<li>mod_python is installed. Now we just need to add following lines to /etc/httpd/conf/httpd.conf to make it load with apache.<br />
<code>LoadModule python_module modules/mod_python.so<br />
PythonOption mod_python.mutex_directory "/tmp"<br />
PythonOption mod_python.mutex_locks 8</code></li>
</ol>
<h2>Saving the EC2 instance on S3</h2>
<p>You will loose all settings and configurations as you will terminate the instance. We need to save instance as our own AMI at this stage.</p>
<ol>
<li>Download PSCP from <a href="http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe" target="_blank">http://the.earth.li/~sgtatham/putty/latest/x86/pscp.exe</a> and run the following command in command prompt to transfer our X.509 certificate to the server for future use.pscp -i id_rsa-gsg-keypair pk-ZG273YPOU74KIXM3UGTDFAIWOARHSSVE.pem cert-ZG273YPOU74KIXM3UGTDFAIWOARHSSVE.pem root@ec2-67-***-***-***.compute-1.amazonaws.com:/mnt (Replace Server name and .pem file names/paths with your files.)</li>
<li> Now we need to download AMI-Tools for backup of our instance. Go back to putty, log into the server as described before and run the following set of commands.<br />
<code>cd /tmp<br />
wget http://developer.amazonwebservices.com/connect/entry.jspa?externalID=368&amp;categoryID=88<br />
unzip ec2-ami-tools-1.3-34544.zip<br />
cp -r ec2-ami-tools-1.3-34544/ /usr/local/<br />
export EC2_AMITOOL_HOME=/usr/local/ec2-ami-tools-1.3-34544/<br />
export PATH=$PATH:${EC2_AMITOOL_HOME:-EC2_HOME}/bin<br />
ec2-bundle-vol -d /mnt -k /mnt/pk-ZG273YPOU74KIXM3UGTDFAIWOARHSSVE.pem -c /mnt/cert-ZG273YPOU74KIXM3UGTDFAIWOARHSSVE.pem -u YOUR_AWS_ACCOUNT_ID -r i386 -p mod_python<br />
</code>(Replace YOUR_AWS_ACCOUNT_ID with your account ID) </li>
<li>This will take some time and will create image files in /mnt. Now we will upload these image files to S3 using this command<br />
<code>ec2-upload-bundle -b  -m /mnt/image.manifest.xml -a  -s </code><br />
 <br />
It will take some time.</li>
<li>Now we need to register our image so that AWS can locate it.<br />
<code>ec2-register /image.manifest.xml</code> <br />
You will get you AMI id, safe it for future use. </li>
<li>Now you can safely terminate your instance.</li>
</ol>
<h2>Installing django</h2>
<ol>
<li>Use the following commands to install django:<br />
<code>cd /usr/local<br />
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk<br />
ln -s `pwd`/django-trunk/django /usr/lib/python2.4/site-packages/django<br />
ln -s /usr/local/django-trunk/django/bin/django-admin.py /usr/local/bin</code></li>
<li>Edit the httpd.conf at /etc/httpd/conf/httpd.conf and add following lines:<br />
&lt;Location &#8220;/mysite/&#8221;&gt;<br />
SetHandler python-program<br />
PythonHandler django.core.handlers.modpython<br />
SetEnv DJANGO_SETTINGS_MODULE mysite.settings<br />
PythonOption django.root /mysite<br />
PythonDebug On<br />
PythonPath &#8220;['/path/to/project'] + sys.path&#8221;<br />
&lt;/Location&gt;<br />
 </li>
<li>Restart the apache and you are ready to go <img src='http://www.dottostring.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F10%2Fdjango-deployment-on-amazon-ec2-step-by-step-tutorial%2F';
  addthis_title  = 'Django+deployment+on+Amazon+EC2+%26%238211%3B+Step+by+step+tutorial';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/10/django-deployment-on-amazon-ec2-step-by-step-tutorial/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Argument &#8220;xxxxxx&#8221; for option &#8220;xxxxxx&#8221; is not valid. The command line parameters are invalid</title>
		<link>http://www.dottostring.com/2009/08/argument-xxxxxx-for-option-xxxxxx-is-not-valid-the-command-line-parameters-are/</link>
		<comments>http://www.dottostring.com/2009/08/argument-xxxxxx-for-option-xxxxxx-is-not-valid-the-command-line-parameters-are/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 09:00:36 +0000</pubDate>
		<dc:creator>ahsan</dc:creator>
				<category><![CDATA[Integaration Services]]></category>
		<category><![CDATA[SQL Jobs]]></category>
		<category><![CDATA[SQLServer]]></category>
		<category><![CDATA[SSIS]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=378</guid>
		<description><![CDATA[If you recieve this error &#8216;Argument &#8220;xxxx&#8221; for option &#8220;xxxx&#8221; is not valid&#8217; while running an SSIS/DTS Package through a job as a job step the you have come to the right place.
SYMPTOMS: The package when executes individually runs successfully. But when executing the package through sql server job it crashes with error in the [...]]]></description>
			<content:encoded><![CDATA[<p>If you recieve this error &#8216;Argument &#8220;xxxx&#8221; for option &#8220;xxxx&#8221; is not valid&#8217; while running an SSIS/DTS Package through a job as a job step the you have come to the right place.</p>
<p><strong>SYMPTOMS:</strong> The package when executes individually runs successfully. But when executing the package through sql server job it crashes with error in the job history.</p>
<p><strong>SOLUTION:</strong> The solution is simple there is a problem with your command line option for the job step. Modify it to get the package running.</p>
<p><strong>EXAMPLE:</strong> Until now you may be unclear that what i am talking about. Let me illustrate with an example. I created an SSIS package which executes successfully without a job. But when i make it a part of job it crashes with the above mentioned error.</p>
<p>The auto-generated command line when i select the data sources was</p>
<blockquote><p>/SQL &#8220;\DVA_PNC_DTS&#8221; /SERVER &#8220;SERVER01&#8243; /CONNECTION &#8220;Database Connection ADO&#8221;;&#8221;\&#8221;Data Source=SERVER03;User ID=User;Initial Catalog=&#8221;"DB1&#8243;&#8221;;Persist Security Info=True;&#8221; /CONNECTION &#8220;Database Connenction&#8221;;&#8221;\&#8221;Data Source=SERVER04;User ID=User;Initial Catalog=DB2;Provider=SQLNCLI.1;Persist Security Info=True;Auto Translate=False;&#8221; /CONNECTION &#8220;Input Connection&#8221;;&#8221;C:\Schema.csv&#8221; /CONNECTION Output;&#8221;C:\Output.txt&#8221; /MAXCONCURRENT &#8221; -1 &#8221; /CHECKPOINTING OFF</p></blockquote>
<p>I manually edit the command line and remove some extra quotes and backslashes and it started working perfectly It looks like this:</p>
<blockquote><p>/SQL &#8220;\DVA_PNC_DTS&#8221; /SERVER SERVER01  /CONNECTION &#8220;Database Connection ADO&#8221;;&#8221;Data Source=SERVER03;User ID=User;Initial Catalog=DB1;Persist Security Info=True;&#8221; /CONNECTION &#8220;Database Connenction&#8221;;&#8221;Data Source=SERVER04;User ID=User;Initial Catalog=DB2;Provider=SQLNCLI.1;Persist Security Info=True;Auto Translate=False;&#8221; /CONNECTION &#8220;Input Connection&#8221;;&#8221;C:\Schema.csv&#8221; /CONNECTION Output;&#8221;C:\Output.txt&#8221; /MAXCONCURRENT &#8221; -1 &#8221; /CHECKPOINTING OFF /REPORTING E</p></blockquote>
<p>Hope this may help anyone.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F08%2Fargument-xxxxxx-for-option-xxxxxx-is-not-valid-the-command-line-parameters-are%2F';
  addthis_title  = 'Argument+%26%238220%3Bxxxxxx%26%238221%3B+for+option+%26%238220%3Bxxxxxx%26%238221%3B+is+not+valid.+The+command+line+parameters+are+invalid';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/08/argument-xxxxxx-for-option-xxxxxx-is-not-valid-the-command-line-parameters-are/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Software Engineering &#8211; Design Patterns</title>
		<link>http://www.dottostring.com/2009/04/software-engineering-design-patterns/</link>
		<comments>http://www.dottostring.com/2009/04/software-engineering-design-patterns/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 03:39:25 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[Adapter]]></category>
		<category><![CDATA[Advantages Design Patterns]]></category>
		<category><![CDATA[Behavioral Design Pattern]]></category>
		<category><![CDATA[Composite]]></category>
		<category><![CDATA[Creational Design Pattern]]></category>
		<category><![CDATA[Decorator]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Disadvantages Design Patterns]]></category>
		<category><![CDATA[Facade]]></category>
		<category><![CDATA[Singleton]]></category>
		<category><![CDATA[Structural Design Pattern]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=344</guid>
		<description><![CDATA[Whats is a Design Pattern?
Design Pattern can be treated as tools used to solve a particular type of problem (mostly a recurring problem over the years). it also proves as a handy shared vocabulary which developers can use while discussing a particular problem at hand.
&#8220;Each pattern describes a problem which occurs over and over again [...]]]></description>
			<content:encoded><![CDATA[<h4><span style="color: #333399;">Whats is a Design Pattern?</span></h4>
<p>Design Pattern can be treated as tools used to solve a particular type of problem (mostly a recurring problem over the years). it also proves as a handy shared vocabulary which developers can use while discussing a particular problem at hand.</p>
<p><em>&#8220;Each pattern describes a problem which occurs over and over again in our  environment, and then describes the core of the solution to that problem, in  such a way that you can use this solution a million times over, without ever  doing it the same way twice&#8221; - <a href="http://en.wikipedia.org/wiki/Christopher_Alexander">Christopher Alexander</a></em></p>
<h4><span style="color: #333399;">Why use a Design Pattern?</span></h4>
<p>They are well tested and refined solutions discovered by software engineers over the years and knowing them can help us disintegrate problems very quickly and efficiently. like for example if we have a scenario where we are required to notify a certain number of class/clients whenever there is  an event or change in data of a class, we use <strong>Observer Pattern.</strong></p>
<h4><span style="color: #333399;">Types of Design Patterns</span></h4>
<p>Design Patterns can be classified into three broad categories.</p>
<ul>
<li><strong>Creational </strong><em>- what should be the process of object creation in a particular design problem.</em></li>
<li><strong>Structural </strong><em>- what should be the structure of classes/objects, helps you design your class compositions while addressing a particular design problem.</em></li>
<li><strong>Behavioral </strong><em>- how classes should communicate/interact with each other in order to make a design model work.</em></li>
</ul>
<p>I will provide a matrix below which will mention the defination/description,advantages and disadvantages of  some of the most commonly used design patterns.</p>
<table style="width: 100%;" border="0" align="left">
<tbody>
<tr style="color: #FFFFFF" bgcolor="#0066CC">
<td style="width: 15%;">Pattern</td>
<td style="width: 25%;">Description</td>
<td style="width: 30%;">Advantages</td>
<td style="width: 30%;">Disadvantages</td>
</tr>
<tr bgcolor="#E9E9E9">
<td style="width: 15%; text-align: left; vertical-align: top;"><strong>Singleton</strong><br />
(Creational) </td>
<td style="width: 25%; text-align: left; vertical-align: top;">Provides a model where a class can only<br />
have a single instance.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-gives you control of the instantiation of the object, ensuring that<br />
only single object exits of the (singleton) class.    </p>
<p>-can provide you with a class with global access which can be used for<br />
various tasks. e.g. Multi-threading, utility tasks e.t.c.</p>
<p>-reduces the load of object creation and destruction.</p>
<p>-can act as a service provider for your application or in other words<br />
whenever you need a manager to manage a particular task, use singleton.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-global access<br />
can prove in high coupling of the singleton object and potential changes<br />
to it can cause a software ripple effect.    </p>
<p>-unnecessary use of the singleton can result in a performance hit, its<br />
some time better to instantiate object as needed rather then have them<br />
all the time in memory.</p>
<p>-if your singleton object contains locks then it can increase the<br />
overall wait time for the application where one class is waiting for the<br />
other class to finish.</td>
</tr>
<tr bgcolor="#E9E9E9">
<td style="width: 15%; text-align: left; vertical-align: top;"><strong>Adapter<br />
<span style="font-weight: normal;">(Structural)</span> </strong></td>
<td style="width: 25%; text-align: left; vertical-align: top;">Converts one<br />
interface to an other interface, effectively facilitating classes to<br />
work together which otherwise cannot due to their incompatible interfaces.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-code for<br />
target and the adaptee(source) does not need any modification, therefore<br />
no ripple effects.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-sometimes<br />
adapters can contain too much code and might appear that changes to the<br />
actual classes could have been easier, so think wisely before you write<br />
an adapter.    </p>
<p>-adds an additional layer of code and all the conversions between<br />
interfaces can effect the performance</p>
<p>-Might not be able to provide all the functionalities because there can<br />
be cases where level of abstraction is high in the adaptee and hence only few methods are provided<br />
through respective interfaces .</td>
</tr>
<tr bgcolor="#E9E9E9">
<td style="width: 15%; text-align: left; vertical-align: top;"><strong>Composite</strong><br />
(Structural) </td>
<td style="width: 25%; text-align: left; vertical-align: top;">Facilitates<br />
modeling of tree structures which  represents part-whole hierarchies .    </p>
<p>examples could Menus, File Structures, Drawing Objects on a Canvas</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-Constructs<br />
part-whole relationship    </p>
<p>-Easier to add new components which exhibit the same recursive behavior.</p>
<p>-Clients can treat each object and compositions uniformily.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-there is no<br />
basic disadvantage of composite pattern.</td>
</tr>
<tr bgcolor="#E9E9E9">
<td style="width: 15%; text-align: left; vertical-align: top;"><strong>Decorater</strong><br />
(Structural) </td>
<td style="width: 25%; text-align: left; vertical-align: top;">this pattern<br />
is used to add new behaviors to an existing class to provide <br />
easier/comprehensive method calls, effectively wrapping the an existing<br />
class to provide additional functionality.    </p>
<p>(another definition)decorator pattern is used to extend the<br />
functionality of the existing class without modifying its code.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-lets clients the ease of code.    </p>
<p>-takes care of the steps that client does not need to focus while using<br />
a particular class. e.g. decExecuteDataSet function can open the<br />
connection, execute the DataSet and then close the connection.</p>
<p>-Decorator pattern can be used instead of Sub classing an object.<br />
Subclassing adds behavior at compile time where as decorator pattern<br />
adds behavior at runtime.</p>
<p>-Decorate makes use of interfaces and concrete implementations providing<br />
an unlimited amount of customization without having to change clients<br />
using it.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-Wrapper<br />
classes effectively are an extra layer and can decrease efficiency (but<br />
the performance hit here can be negligible).</td>
</tr>
<tr bgcolor="#E9E9E9">
<td style="width: 15%; text-align: left; vertical-align: top;"><strong>Facade</strong><br />
(Structural) </td>
<td style="width: 25%; text-align: left; vertical-align: top;">Facade<br />
provides a single interface to manage several sub classes effectively<br />
simplifying the overall process.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-makes the<br />
communication with a set of applications/classes much easier and neat.</td>
<td style="width: 30%; text-align: left; vertical-align: top;">-whenever<br />
there is a new component in the overall process, it requires<br />
modification in the facade layer.</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Advantages and Disadvantages of Design Patterns can be debatable from case to case scenarios, a basic rule for a good designer is to analyze the whole problem at hand and draw concrete conclusions on whether a design pattern should be applied or not. Over use of  design patterns might result in a significant performance hit, therefore determine tradeoffs wisely.</p>
<p>Cheers.</p>
<p>Dont forget to leave Comments/Feedback.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F04%2Fsoftware-engineering-design-patterns%2F';
  addthis_title  = 'Software+Engineering+%26%238211%3B+Design+Patterns';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/04/software-engineering-design-patterns/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding support for .NET datatypes to ExtJs Grid (DateTime, Boolean and Currency)</title>
		<link>http://www.dottostring.com/2009/04/adding-support-for-net-datatypes-to-extjs-grid-datetime-boolean-and-currency/</link>
		<comments>http://www.dottostring.com/2009/04/adding-support-for-net-datatypes-to-extjs-grid-datetime-boolean-and-currency/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:10:56 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ExtJs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[renderer]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=356</guid>
		<description><![CDATA[In our previous examples we had been using plain Strings in ExtJs grid.
Have a quick look at them:

On-Demand Paging using ExtJS Grid with Client-Centric ASP.NET AJAX (WebMethods)
Adding server side sorting to ExtJS Grid using WebMethods in ASP.NET

Today, we are going to deal with other Data types like DateTime, Boolean, Currency et cetera. For this purpose, [...]]]></description>
			<content:encoded><![CDATA[<p>In our previous examples we had been using plain Strings in ExtJs grid.<br />
Have a quick look at them:</p>
<ul>
<li><a href="/2008/12/on-demand-paging-using-extjs-grid-with-client-centric-asp-dot-net-ajax-webmethods/" target="_blank">On-Demand Paging using ExtJS Grid with Client-Centric ASP.NET AJAX (WebMethods)</a></li>
<li><a href="/2009/03/adding-server-side-sorting-to-extjs-grid-using-webmethods-in-aspnet/" target="_blank">Adding server side sorting to ExtJS Grid using WebMethods in ASP.NET</a></li>
</ul>
<p>Today, we are going to deal with other Data types like DateTime, Boolean, Currency et cetera. For this purpose, ExtJs ColumnModel provides and excellent config option <code><a href="http://extjs.com/deploy/ext/docs/output/Ext.grid.ColumnModel.html#config-renderer" target="_blank">renderer</a></code></p>
<p>Lets start with builtin format options of ExtJs. </p>
<pre name="code" class="js">
// create the grid
        var grid = new Ext.grid.EditorGridPanel({
            el:'grid-employees',
            width:650,
            height:300,
            title:'Sample Employees',
            store: store,
            stripeRows: true,
            loadMask: true,
            enableHdMenu: false,

            // grid columns
            columns:[{
                id: 'EmployeeID',
                dataIndex: 'EmployeeID',
                hidden:true
            },{
                header: "Login ID",
                dataIndex: 'LoginID',
                width: 150,
                sortable:true

            },{
                header: "Title",
                dataIndex: 'Title',
                width: 200,
                sortable:true
            },{
                header: "Birth Date",
                dataIndex: 'BirthDate',
                width: 100,
                sortable:true
            },{
                header: "Gender",
                dataIndex: 'Gender',
                width: 70,
                sortable:true
            },{
                header: "Salary",
                dataIndex: 'Salary',
                width: 70,
                renderer: 'usMoney',
                sortable:true
            },{
                header: "Salaried",
                dataIndex: 'SalariedFlag',
                width: 50,
                sortable:true
            }],
            // put paging bar on the bottom
            bbar: pagingBar
        });
</pre>
<p>Notice that for the dataIndex Salary, we have renderer option equal to <code><a href="http://extjs.com/deploy/ext/docs/output/Ext.util.Format.html#usMoney" target="_blank">usMony</a></code>. This will render all values in this column as usMoney. </p>
<p>Now lets play with some custom renderers. I have written two custom rederers. One is for DateTime object of .NET and the other is for Boolean object.</p>
<pre name="code" class="js">
        // Our own date renderer function
        function formatDate(value){
            return value ? value.dateFormat('F d, Y') : '';
        };

        // Our own boolean renderer
        function formatTrueFalse(value) {
            return value ? '&amp;#10003;': '&amp;#9747;';
        }
</pre>
<p>These functions are quite simple. They just return the formatted strings to be used in ColumnModel. Now we will use these renderers in our ColumnModel.</p>
<pre name="code" class="js">
        // create the grid
        var grid = new Ext.grid.EditorGridPanel({
            el:'grid-employees',
            width:650,
            height:300,
            title:'Sample Employees',
            store: store,
            stripeRows: true,
            loadMask: true,
            enableHdMenu: false,

            // grid columns
            columns:[{
        	    id: 'EmployeeID',
                dataIndex: 'EmployeeID',
                hidden:true
            },{
                header: "Login ID",
                dataIndex: 'LoginID',
                width: 150,
                sortable:true

            },{
                header: "Title",
                dataIndex: 'Title',
                width: 200,
                sortable:true
            },{
                header: "Birth Date",
                dataIndex: 'BirthDate',
                width: 100,
                renderer: formatDate,
                sortable:true
            },{
                header: "Gender",
                dataIndex: 'Gender',
                width: 70,
                sortable:true
            },{
                header: "Salary",
                dataIndex: 'Salary',
                width: 70,
                renderer: 'usMoney',
                sortable:true
            },{
                header: "Salaried",
                dataIndex: 'SalariedFlag',
                width: 50,
                renderer: formatTrueFalse,
                sortable:true
            }],
            // put paging bar on the bottom
            bbar: pagingBar
        });
</pre>
<p>And that&#8217;s all <img src='http://www.dottostring.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now you will have a beautifully rendered grid. </p>
<p><img src="http://www.dottostring.com/wp-content/uploads/2009/04/custom-renderer-extjs-grid.png" alt="custom-renderer-extjs-grid" title="custom-renderer-extjs-grid" width="652" height="302" class="aligncenter size-full wp-image-358" /></p>
<p>You can also add images in grid in this way. Try replacing Gender in this example with appropriate icons. I leave this as an exercise for you.</p>
<p><a href='http://www.dottostring.com/wp-content/uploads/2009/04/dottostring-extjs-grid-fields.zip'>Download the example code</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F04%2Fadding-support-for-net-datatypes-to-extjs-grid-datetime-boolean-and-currency%2F';
  addthis_title  = 'Adding+support+for+.NET+datatypes+to+ExtJs+Grid+%28DateTime%2C+Boolean+and+Currency%29';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/04/adding-support-for-net-datatypes-to-extjs-grid-datetime-boolean-and-currency/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JQuery Communicating with Web Service to check for duplicate emails</title>
		<link>http://www.dottostring.com/2009/04/jquery-communicating-with-web-service-to-check-for-duplicate-emails/</link>
		<comments>http://www.dottostring.com/2009/04/jquery-communicating-with-web-service-to-check-for-duplicate-emails/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 15:36:34 +0000</pubDate>
		<dc:creator>ahsan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[Web Service]]></category>
		<category><![CDATA[WebService]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=331</guid>
		<description><![CDATA[Few days ago I had a task that on user registration I had to check the email address of the user. When the user enters the email address the application should check the database that if the email exists in the database user will not be able to add it again and the whole task [...]]]></description>
			<content:encoded><![CDATA[<p>Few days ago I had a task that on user registration I had to check the email address of the user. When the user enters the email address the application should check the database that if the email exists in the database user will not be able to add it again and the whole task should be done in a way that user enters the email in a textbox and then starts filling the other form and system in the meanwhile automatically checks the existence of email in the database. I used <strong>Jquery</strong> for this task, the selection of jquery can be debatable but its not the issue at hand. I made a web service which communicates with my database. In the web service I have a method  named CheckEmail which checks the existence of email in the particular table. The web service looks like this:</p>
<pre name="code" class="vb">Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Web.Script.Services
Imports System.Data.OleDb

&lt;WebService(Namespace:="http://tempuri.org/")&gt; _
&lt;WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _
&lt;ScriptService()&gt; _
&lt;Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()&gt; _
Public Class Service
Inherits System.Web.Services.WebService

&lt;WebMethod()&gt; _
Public Function CheckEmail(ByVal email As String) As String
Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionStringManual").ToString()
Dim connection As OleDbConnection = New OleDbConnection(connectionString)
connection.Open()
Dim sqlString As String = "Select count(*) from Customers where CustomerEmail =?"
Dim command As OleDbCommand = New OleDbCommand(sqlString, connection)
command.Parameters.AddWithValue("CustomerEmail", email)
Return command.ExecuteScalar()

End Function
End Class</pre>
<p>This web service returns an integer based on the count of rows after running the query.</p>
<p>I have an aspx page which looks like the code below:</p>
<pre name="code" class="html">&lt;body&gt;
&lt;form id="form1" runat="server"&gt;
&lt;div&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;
Email:
&lt;/td&gt;
&lt;td&gt;
&lt;asp:TextBox ID="txtEmail" runat="server" &gt;&lt;/asp:TextBox&gt;&lt;span id="spErrorMessage"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
Password:
&lt;/td&gt;
&lt;td&gt;
&lt;asp:TextBox ID="txtPassword" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;/table&gt;
&lt;/div&gt;

&lt;/form&gt;
&lt;/body&gt;</pre>
<p>And finally the last but the most important section of  Jquery in the head section of the page.</p>
<pre name="code" class="js">&lt;head runat="server"&gt;
&lt;script src="jquery-1.3.2.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;

$(function()
{
$("#&lt;%= txtEmail.ClientID %&gt;").change(DuplicateEmailCheck);
}
);

function DuplicateEmailCheck()
{
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{email: '" + $('#&lt;%= txtEmail.ClientID %&gt;').val() + "'}",
dataType: "json",
url: "http://localhost:1561/TestWebService/Service.asmx/CheckEmail",
success: function(response)
{
$("#spErrorMessage").empty();
if (response.d != "0")
{
$("#spErrorMessage").html('Email address already exists.');
}
}
});

}
&lt;/script&gt;</pre>
<p>The first script section contains the reference to the latest jquery library till date. You can download it from internet very easily. The second script section does the real magic but its very easy. The first function just hooks the txtEmail textbox with the DuplicateEmailCheck function. The DuplicateEmailCheck function makes an ajax call to the web service which we created above. Now based on the result the span belonging to the textbox will be populated if email already exists.</p>
<p>Thats all folks, don&#8217;t forget to leave feedback/suggestions.</p>
<p>Cheers.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F04%2Fjquery-communicating-with-web-service-to-check-for-duplicate-emails%2F';
  addthis_title  = 'JQuery+Communicating+with+Web+Service+to+check+for+duplicate+emails';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/04/jquery-communicating-with-web-service-to-check-for-duplicate-emails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Adding server side sorting to ExtJS Grid using WebMethods in ASP.NET</title>
		<link>http://www.dottostring.com/2009/03/adding-server-side-sorting-to-extjs-grid-using-webmethods-in-aspnet/</link>
		<comments>http://www.dottostring.com/2009/03/adding-server-side-sorting-to-extjs-grid-using-webmethods-in-aspnet/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 08:03:01 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[ExtJs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[serverside]]></category>
		<category><![CDATA[Sorting]]></category>
		<category><![CDATA[WebMethod]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=312</guid>
		<description><![CDATA[We will continue with the example in previous post:
On-Demand Paging using ExtJS Grid with Client-Centric ASP.NET AJAX (WebMethods)

First of all we will add config option sortable:true to all columns we want to be sortable
So, the grid code will look like this:

        // create the grid
    [...]]]></description>
			<content:encoded><![CDATA[<p>We will continue with the example in previous post:</p>
<p><a href="http://www.dottostring.com/2008/12/on-demand-paging-using-extjs-grid-with-client-centric-asp-dot-net-ajax-webmethods/">On-Demand Paging using ExtJS Grid with Client-Centric ASP.NET AJAX (WebMethods)</a></p>
<p><img class="aligncenter size-full wp-image-315" title="ExtJS Serverside Sorting Example" src="http://www.dottostring.com/wp-content/uploads/2009/03/extjs-serverside-sorting.jpg" alt="ExtJS Serverside Sorting Example" width="406" height="302" /></p>
<p>First of all we will add config option <code>sortable:true</code> to all columns we want to be sortable</p>
<p>So, the grid code will look like this:</p>
<pre name="code" class="js">
        // create the grid
        var grid = new Ext.grid.GridPanel({
            el:'grid-products',
            width:405,
            height:300,
            title:'Adventure Works Products',
            store: store,
            stripeRows: true,
            loadMask: true,
            enableHdMenu: false,

            // grid columns
            columns:[{
        	    header: "id",
        	    id: 'ProductID',
                dataIndex: 'ProductID',
                hidden:true
            },{
                header: "Product Name",
                dataIndex: 'Name',
                width: 200,
                sortable:true
            },{
                header: "Product Number",
                dataIndex: 'ProductNumber',
                width: 100,
                sortable:true
            },{
                header: "Safety Stock Level",
                dataIndex: 'SafetyStockLevel',
                width: 100
            }],
            // put paging bar on the bottom
            bbar: pagingBar
        });</pre>
<p>Now, you can sort the grid on client side. But this is sorting within a page only. We want to sort the grid for all products which can be achieved by server side sorting only.</p>
<p>Lets make it request the server for sorting. We have to add <code>remoteSort:true</code> to our JsonStore. So the JsonStore code will look like this:</p>
<pre name="code" class="js">// create the Data Store
        var store = new Ext.data.JsonStore({
            root: 'lstProducts',
            totalProperty: 'RowCount',
            idProperty: 'ProductID',
		    fields: [
                'Name','ProductID', 'ProductNumber', 'ReorderPoint','SafetyStockLevel'
            ],
            remoteSort:true,
            proxy:pmProxy
        });</pre>
<p>Now, all of sorting information will go with params to PageMethodProxy as:</p>
<ul>
<li><code>sort</code> having the id of the column</li>
<li><code>dir</code> for direction of sorting (it can have values <code>ASC</code> or <code>DESC</code>)</li>
</ul>
<p>We have to change the PageMethodProxy a little bit to forward this sorting information to WebMethod. After this our PageMethodProxy code will look like this:</p>
<pre name="code" class="js">Ext.data.PageMethodProxy = function(config){
	Ext.data.PageMethodProxy.superclass.constructor.call(this);
	Ext.apply(this, config);
};

Ext.data.PageMethodProxy.TRANS_ID = 1000;
Ext.data.PageMethodProxy.arr_trans = Array();

Ext.extend(Ext.data.PageMethodProxy, Ext.data.DataProxy, {
    load : function(params, reader, callback, scope, arg) {
        if(this.fireEvent("beforeload", this, params) !== false){
            var p = Ext.apply(params, this.extraParams);
            var transId = ++Ext.data.PageMethodProxy.TRANS_ID;
            var trans = {
                id : transId,
                params : params,
                arg : arg,
                callback : callback,
                scope : scope,
                reader : reader
            };
            if(typeof p.sort == "undefined")
                p.sort = "";
            if(typeof p.dir == "undefined")
                p.dir = "";

            eval("PageMethods." + this.pageMethod + "(p.start,p.limit,p.sort,p.dir,this.handleResponse)");

            Ext.data.PageMethodProxy.arr_trans[Ext.data.PageMethodProxy.TRANS_ID] = trans;
        }
        else{
            callback.call(scope||this, null, arg, false);
        }

    },	

    isLoading : function(){
        return this.trans ? true : false;
    },

    abort : function(){
        if(this.isLoading()){
            this.destroyTrans(this.trans);
        }
    },

    handleResponse : function(o){
        var trans = Ext.data.PageMethodProxy.arr_trans[Ext.data.PageMethodProxy.TRANS_ID];
        var result;
        try {
            result = trans.reader.readRecords(o);
        }catch(e){
            this.fireEvent("loadexception", this, o, trans.arg, e);
            trans.callback.call(trans.scope||window, null, trans.arg, false);
            return;
        }
        this.trans = false;
        trans.callback.call(trans.scope||window, result, trans.arg, true);
    }
});</pre>
<p>Notice that we have added check for undefined sorting parameters. This is the case when no sorting is applied. We have to handle this on client side.</p>
<p>Now finally add the sorting code to the WebMethod which will handle the sorting parameters. The Web Method code will look like this now</p>
<pre name="code" class="c#">
    [System.Web.Services.WebMethod]
    public static ProductList GetProducts(int PageNumber,int MaximumRows,string SortColumnName, string SortDirection)
    {
        //calculating the start row index
        int Start = PageNumber + 1;
        //calculating the end row index
        int End = PageNumber + MaximumRows;

        ProductList productList = new ProductList();
        //setting up sql connection to execute the query
        SqlConnection sqlConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True");
        sqlConnection.Open();
        //setting up the command object with a parameterized query and sql connection
        using (SqlCommand command = new SqlCommand(GetQuery(SortColumnName,SortDirection), sqlConnection))
        {
            //Creating Sql Start Paramter
            SqlParameter StartParameter = new SqlParameter();
            StartParameter.DbType = DbType.Int32;
            StartParameter.ParameterName = "startRowIndex";
            StartParameter.Value = Start;
            //Creating Sql End Parameter
            SqlParameter EndParameter = new SqlParameter();
            EndParameter.DbType = DbType.Int32;
            EndParameter.ParameterName = "endRowIndex";
            EndParameter.Value = End;
            //Adding Start Parameter to the command object
            command.Parameters.Add(StartParameter);
            //Adding End Parameter to the command object
            command.Parameters.Add(EndParameter);
            //Executing Reader
            using (IDataReader reader = command.ExecuteReader())
            {
                //Creating a list of objects from the fetched rows
                while (reader.Read())
                {
                    productList.lstProducts.Add(ConstructProduct(reader));
                }
            }
        }
        //closing the connection
        sqlConnection.Close();
        //Assigning total row count for the given query so that it can
        //be used by the grid to set up total number of pages
        productList.RowCount = GetRowCount();
        return productList;
    }

    private static String GetQuery(String ColumnName,String SortDirection)
    {

        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.Append(" SELECT * FROM ( ");
        if(!ColumnName.Trim().Equals(String.Empty) &#038;&#038; !SortDirection.Trim().Equals(String.Empty))
            stringBuilder.Append(" SELECT	ROW_NUMBER() OVER (ORDER BY "+ColumnName.Trim().ToUpper()+" "+ SortDirection.Trim().ToUpper()+") AS row_num,ProductID,[Name],ProductNumber,SafetyStockLevel,ReorderPoint ");
        else
            stringBuilder.Append(" SELECT	ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS row_num,ProductID,[Name],ProductNumber,SafetyStockLevel,ReorderPoint ");
        stringBuilder.Append(" FROM	Product ");
        stringBuilder.Append(" ) AS TempTable WHERE row_num>=@startRowIndex AND row_num<=@endRowIndex ");
        return stringBuilder.ToString();
    }
</pre>
<p>And thats all. We have successfully added Server side sorting to our existing code. This will work with paging too.</p>
<p>You can download the complete project here:<a href='http://www.dottostring.com/wp-content/uploads/2009/03/dottostringextjs_grid_sorting.zip'>.toString() - ExtJS Serverside Grid Sorting</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F03%2Fadding-server-side-sorting-to-extjs-grid-using-webmethods-in-aspnet%2F';
  addthis_title  = 'Adding+server+side+sorting+to+ExtJS+Grid+using+WebMethods+in+ASP.NET';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/03/adding-server-side-sorting-to-extjs-grid-using-webmethods-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ASP.NET Tutorials &#8211; [Part 04] ASP.NET 3.5 Controls and Event Handlers III</title>
		<link>http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/</link>
		<comments>http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 23:15:18 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[ASP.NET Controls]]></category>
		<category><![CDATA[AssociatedControlID]]></category>
		<category><![CDATA[BackColor]]></category>
		<category><![CDATA[BorderColor]]></category>
		<category><![CDATA[BorderStyle]]></category>
		<category><![CDATA[BorderWidth]]></category>
		<category><![CDATA[Control]]></category>
		<category><![CDATA[CssClass]]></category>
		<category><![CDATA[Encode]]></category>
		<category><![CDATA[Font]]></category>
		<category><![CDATA[ForeColor]]></category>
		<category><![CDATA[Label]]></category>
		<category><![CDATA[Literal Control]]></category>
		<category><![CDATA[Microsofto Visual Studio 2008]]></category>
		<category><![CDATA[Mode]]></category>
		<category><![CDATA[PassThrough]]></category>
		<category><![CDATA[runat]]></category>
		<category><![CDATA[runat="server"]]></category>
		<category><![CDATA[Standard Control]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[ToolTip]]></category>
		<category><![CDATA[Transform]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=250</guid>
		<description><![CDATA[In this Part we are working with some of the Standard Controls in Details.
Standard Controls
Standard controls contain controls which help the developers to perform useful operations for example displaying information, taking user input in a textbox, displaying a drop down box, ListBox and many more. we will take look at some of them in detail.
Label [...]]]></description>
			<content:encoded><![CDATA[<p>In this Part we are working with some of the Standard Controls in Details.</p>
<h3>Standard Controls</h3>
<p>Standard controls contain controls which help the developers to perform useful operations for example displaying information, taking user input in a textbox, displaying a drop down box, ListBox and many more. we will take look at some of them in detail.</p>
<h4><span style="color: #000080;">Label Control</span></h4>
<p>label control is used when you need to dynamically display/change data on the webpage. we already saw a sample code in the last part (part 03) which changed text of the label dynamically on button&#8217;s click and TextBox&#8217;s TextChanged Event. There are plenty of Properties with which we play around with.</p>
<div id="attachment_251" class="wp-caption aligncenter" style="width: 204px"><a href="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-property-panel.jpg"><img class="size-medium wp-image-251" title="ASP.NET Standard Controls - Label - Property Panel" src="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-property-panel-194x300.jpg" alt="ASP.NET Standard Controls - Label - Property Panel" width="194" height="300" /></a><p class="wp-caption-text">ASP.NET Standard Controls - Label - Property Panel</p></div>
<p>following are some of the most used properties witha  brief description</p>
<ul>
<li><strong>BackColor &#8211; </strong>sets the color of the background of the label control</li>
<li><strong>BorderColor &#8211; </strong>sets the color of the border of the label control</li>
<li><strong>BorderStyle &#8211; </strong>lets you set the style of the border e.g. <strong>NotSet, None, Dotted, Dashed, Solid, Double, Groove, Ridge, Inset, and Outset.</strong></li>
<li><strong>BorderWidth &#8211; </strong>lets you set the width of the border</li>
<li><strong>CssClass -</strong>lets you set CSS class for label.</li>
<li><strong>Font &#8211; </strong>lets you configure various font properties e.g <strong>Bold, Italic, Name, Names</strong>, <strong>Overline, Size, Strikeout, Underline</strong></li>
<li><strong>ForeColor &#8211; </strong>lets you<strong> </strong>set the color of the content of the label.</li>
<li><strong>ToolTip &#8211; </strong>lets you set the tool tip for the label control.</li>
<li><strong>Style &#8211; </strong>lets you set inline style attribute for the label control.</li>
</ul>
<p>now lets have a look at a sample which illustrates the use of these properties.</p>
<pre name="code" class="html">&lt;%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;

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

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;[.toString()] Standard Controls - http://dottostring.com&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
        &lt;asp:Label ID="Label1"
            runat="server"
            Text="label text goes here"
            BackColor="#FF9966"
            BorderColor="Black"
            BorderStyle="Double"
            BorderWidth="2px"
            Font-Bold="True"
            Font-Italic="True"&gt;
            &lt;/asp:Label&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<ul>
<li>Run (F5) your website and this is what you will get:</li>
</ul>
<div id="attachment_258" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-properties-demonstration.jpg"><img class="size-medium wp-image-258" title="ASP.NET Standard Controls - Label - Properties Demonstration" src="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-properties-demonstration-300x225.jpg" alt="ASP.NET Standard Controls - Label - Properties Demonstration" width="300" height="225" /></a><p class="wp-caption-text">ASP.NET Standard Controls - Label - Properties Demonstration</p></div>
<p>Labels are frequently used as the labels next to textbox fields in order to identify the information to be entered in those fields.  In order to associate a Label to a TextBox, Label has a property <strong>AssociatedControlID</strong>, setting this property doesn&#8217;t change anything as far as the display is concerned however when the label is clicked by the user it automatically takes the focus to the associated control.</p>
<p>Here is another sample which illustrates the use of <strong>AssociatedControlID </strong>and <strong>CssClass </strong>attributes.</p>
<pre name="code" class="html">&lt;%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;

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

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;[.toString()] Standard Controls - http://www.dottostring.com&lt;/title&gt;
    &lt;style type="text/css"&gt;
        .LabelStyle {
            font-family: "Trebuchet MS";
            font-size: medium;
            font-weight: bold;
            color: #800000;
        }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div &gt;
        &lt;asp:Label ID="Label1"
            runat="server"
            Text="label text goes here"
            BackColor="#FF9966"
            BorderColor="Black"
            BorderStyle="Double"
            BorderWidth="2px"
            Font-Bold="True"
            Font-Italic="True"&gt;
            &lt;/asp:Label&gt;
        &lt;br /&gt;
        &lt;br /&gt;
        &lt;asp:Label
            ID="lblProductName"
            runat="server"
            AssociatedControlID="txtProductName"
            Text="Product Name"
            CssClass="LabelStyle"&gt;
            &lt;/asp:Label&gt;
        &lt;br /&gt;
        &lt;asp:TextBox
            ID="txtProductName"
            runat="server"&gt;
            &lt;/asp:TextBox&gt;
        &lt;br /&gt;
        &lt;asp:Label
            ID="lblProductCode"
            runat="server"
            AssociatedControlID="txtProductCode"
            Text="Product Code"
            CssClass="LabelStyle"&gt;
            &lt;/asp:Label&gt;
        &lt;br /&gt;
        &lt;asp:TextBox
            ID="txtProductCode"
            runat="server"&gt;
            &lt;/asp:TextBox&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<ul>
<li>Run(F5) the website and see the results.</li>
</ul>
<div id="attachment_259" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-properties-demonstration-ii.jpg"><img class="size-medium wp-image-259" title="ASP.NET Standard Controls - Label - Properties Demonstration II" src="http://www.dottostring.com/wp-content/uploads/2009/01/aspnet-standard-controls-label-properties-demonstration-ii-300x225.jpg" alt="ASP.NET Standard Controls - Label - Properties Demonstration II" width="300" height="225" /></a><p class="wp-caption-text">ASP.NET Standard Controls - Label - Properties Demonstration II</p></div>
<h4><span style="color: #000080;">Literal Control</span></h4>
<p>Literal Control is almost the same as the Label Control except for the fact that Literal Control does not render its content inside the Span Tag, you can use it to display text or HTML content. it simply outputs contents assigned to it. Like for example lets say we need to dynamically update the title of the page, this can be done either by  placing a <strong>runat=&#8221;server&#8221; </strong> and  <strong>ID </strong>attributes to the Title Tag and then modify it from the server side or we can simply place a <strong>Literal Control </strong>in the Title Tag and then assign the desired title text to the literal control from the server.</p>
<p>Literal Control possess a useful property called <strong>Mode, </strong>which can be set to one of the following properties.</p>
<ul>
<li><strong>PassThrough &#8211; </strong>Everything assigned to the Text Property is rendered as it is to the browser. for example <em>&#8220;&lt;b&gt;&lt;i&gt;dottostring.com&lt;/i&gt;&lt;/b&gt;&#8221; </em> will print <em><strong>dottostring </strong></em>(in bold and italic)</li>
<li><strong>Transform &#8211; </strong>This will remove all the content from the Text Property of the Literal Control which is not supported by the browser/device it is rendering to. In case of HTML Browser this acts just like <strong>PassThrough</strong></li>
<li><strong>Encode &#8211; </strong>This will encode the all the tag so that they are displayed as it is to the viewer. for example <em>&#8220;&lt;b&gt;&lt;i&gt;dottostring.com&lt;/i&gt;&lt;/b&gt;&#8221; </em> will print &lt;b&gt;&lt;i&gt;dottostring.com&lt;/i&gt;&lt;/b&gt; to the user interface.</li>
</ul>
<p>as we dont have any span tag in the literal control rendered output, therefore we cannot apply any sort of formatting.</p>
<p>now lets look at some samples</p>
<ul>
<li>Add Two Literal Controls, one in the Title Tag and the other inside the body and name them <strong>lTitle </strong>and <strong>lContent </strong>respectively.</li>
<li>in the <strong>Page_Load </strong>Method add the following code.</li>
</ul>
<pre name="code" class="c#">protected void Page_Load(object sender, EventArgs e)
    {
        lTitle.Text = "[.toString()] Standard Controls - http://www.dottostring.com";
        lContent.Text = "&lt;b&gt;&lt;i&gt;dottostring&lt;/i&gt;&lt;/b&gt;";
    }</pre>
<ul>
<li>Run(F5) the application and notice the following results</li>
</ul>
<p> </p>
<div id="attachment_293" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-293" title="ASP.NET Standard Controls - Literal Control Demonstration" src="http://www.dottostring.com/wp-content/uploads/2009/02/aspnet-standard-controls-literal-control-demonstration-300x281.jpg" alt="ASP.NET Standard Controls - Literal Control Demonstration" width="300" height="281" /><p class="wp-caption-text">ASP.NET Standard Controls - Literal Control Demonstration</p></div>
<p>The Title of the page is what we set from the Page_Load Method dynamically and also we can see the other Literal Control which is rendered to display <strong>dottostring </strong> in below the two textboxes. also it is important to note that by Default the Mode Property for Literal Control is set to <strong>Transform</strong>, and since results are being redered to an HTML Browser, Transform and PassThrough will generate the same results, however when we change the <strong>IContent</strong>&#8217;s Mode Property to <strong>Encode </strong>it will also display the markup language on the user interface. effectively converting &#8220;&lt;&#8221; to &#8220;&amp;lt&#8221; and &#8220;&gt;&#8221; to &#8220;&amp;gt;&#8221;.</p>
<p> </p>
<div id="attachment_294" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-294" title="ASP.NET Standard Controls - Literal Control Demonstration - Mode=Encode" src="http://www.dottostring.com/wp-content/uploads/2009/02/aspnet-standard-controls-literal-control-demonstration-modeencode-300x281.jpg" alt="ASP.NET Standard Controls - Literal Control Demonstration - Mode=Encode" width="300" height="281" /><p class="wp-caption-text">ASP.NET Standard Controls - Literal Control Demonstration - Mode=Encode</p></div>
<p>we can clearly see the mark up language now. so Literal Control can be a very handy control in generating HTML content dynamically.</p>
<p>Thats it for this Part04, in this part we learned how to use some Standard Controls and what their important set of properties do. In the next part we will look at other Standard Controls which will enable us to make our interface much more user interactive.</p>
<ul>
<li>Thanks for visiting and waiting patiently for this part, I will be posting more regulary now, so keep in touch and don&#8217;t forget to leave comments/feedback</li>
<li><a rel="attachment wp-att-295" href="http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/dottostring-aspnet-tutorialspart04/">Download Source Code for Part04</a></li>
<li>Cheers !</li>
</ul>
<p>Previous Parts:</p>
<ul>
<li> <a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-1-a-peek-into-aspnet-and-net-framework-3_5/" target="_self">ASP.NET Tutorials &#8211; [Part 01] A peek into ASP.NET and .NET Framework 3.5<br />
</a></li>
<li> <a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i/" target="_self">ASP.NET Tutorials &#8211; [Part 02] ASP.NET 3.5 Controls and Event Handlers I<br />
</a></li>
<li> <a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii/" target="_self">ASP.NET Tutorials &#8211; [Part 03] ASP.NET 3.5 Controls and Event Handlers II<br />
</a></li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F02%2Faspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii%2F';
  addthis_title  = 'ASP.NET+Tutorials+%26%238211%3B+%5BPart+04%5D+ASP.NET+3.5+Controls+and+Event+Handlers+III';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using extjs calendar control (DateField) in ASP.NET</title>
		<link>http://www.dottostring.com/2009/01/using-extjs-calendar-control-datefield-in-aspnet/</link>
		<comments>http://www.dottostring.com/2009/01/using-extjs-calendar-control-datefield-in-aspnet/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 21:36:49 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[ExtJs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Calendar Control]]></category>
		<category><![CDATA[DateField]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=268</guid>
		<description><![CDATA[There are lots of scenarios where you want to use a nice calendar control, without changing server side logic. This short tutorial will enable you to use extjs DateField in ASP.NET as a calendar control and get the value of user input as DateTime object on server side. With extjs DateField you can apply validations, [...]]]></description>
			<content:encoded><![CDATA[<p>There are lots of scenarios where you want to use a nice calendar control, without changing server side logic. This short tutorial will enable you to use extjs DateField in ASP.NET as a calendar control and get the value of user input as DateTime object on server side. With extjs DateField you can apply validations, restrict certain dates, set default date or change it in any way you want.</p>
<p><img class="aligncenter size-full wp-image-269" title="extjs calendar control in ASP.NET" src="http://www.dottostring.com/wp-content/uploads/2009/01/extjs-calendar-aspnet.png" alt="extjs calendar control in ASP.NET" width="207" height="232" /></p>
<p>We start with adding a textbox and a button (We will be converting this textbox to calendar control):</p>
<pre name="code" class="html">
<div id="calendarContainer">
    <asp:TextBox ID="txtCalendar" runat="server" rel="calendar"></asp:TextBox>
</div>

<asp:Button ID="btnSubmit" runat="server" Text="Submit" onclick="btnSubmit_Click" />
</pre>
<p>Notice that we are using <code>rel="calendar"</code> here. We do not want to use name or id attribute here because using a master page, we cannot predict client side id or name of the control. Using rel we can safely select multiple controls on client side.</p>
<p>Now we write our javascript. First of all, select all TextBoxes having <code>rel="calendar"</code> using <code>DomQuery</code>:</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            var textBoxes = Ext.DomQuery.select("input[rel=calendar]");
        });
</pre>
<p>Now loop through each TextBox and convert them to extjs DateField</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            var textBoxes = Ext.DomQuery.select("input[rel=calendar]");
            Ext.each(textBoxes, function(item, id, all){
                var cl = new Ext.form.DateField({
                    allowBlank : false,
                    applyTo: item
                });
            });
        });
</pre>
<p>And thats all <img src='http://www.dottostring.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now you can get the value of selected date on server side like this:</p>
<pre name="code" class="csharp">
DateTime.Parse(txtCalendar.Text);
</pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2009%2F01%2Fusing-extjs-calendar-control-datefield-in-aspnet%2F';
  addthis_title  = 'Using+extjs+calendar+control+%28DateField%29+in+ASP.NET';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2009/01/using-extjs-calendar-control-datefield-in-aspnet/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>ASP.NET Tutorials &#8211; [Part 03] ASP.NET 3.5 Controls and Event Handlers II</title>
		<link>http://www.dottostring.com/2008/12/aspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii/</link>
		<comments>http://www.dottostring.com/2008/12/aspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 15:06:27 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[ASP.NET Controls]]></category>
		<category><![CDATA[Creating New Website]]></category>
		<category><![CDATA[Event Handlers]]></category>
		<category><![CDATA[Microsofto Visual Studio 2008]]></category>
		<category><![CDATA[On Click]]></category>
		<category><![CDATA[runat]]></category>
		<category><![CDATA[runat="server"]]></category>
		<category><![CDATA[Text Changed Event]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=225</guid>
		<description><![CDATA[In the last part (part 02) I gave you an overview of ASP.NET 3.5 Controls and their Event Handlers, in this part I will put forward some samples codes.
Creating an ASP.NET Website

Open Microsoft Visual Studio 2008
Create a new ASP.NET website (File &#8211; &#62; New &#8211; &#62; Website)



Provide the location and name for your website.
From the [...]]]></description>
			<content:encoded><![CDATA[<p>In the last part (part 02) I gave you an overview of ASP.NET 3.5 Controls and their Event Handlers, in this part I will put forward some samples codes.</p>
<h3>Creating an ASP.NET Website</h3>
<ul>
<li>Open Microsoft Visual Studio 2008</li>
<li>Create a new ASP.NET website (File &#8211; &gt; New &#8211; &gt; Website)</li>
</ul>
<p style="text-align: center;">
<div id="attachment_226" class="wp-caption aligncenter" style="width: 488px"><img class="size-full wp-image-226" title="My First Website - Create New Website" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-create-new-website.jpg" alt="My First Website - Create New Website" width="478" height="316" /><p class="wp-caption-text">My First Website - Create New Website</p></div>
<ul>
<li>Provide the location and name for your website.</li>
<li>From the Language drop down you can select the language of your choice (I will be using C# throughout all my articles).</li>
<li>Pressing OK, will create a website project for you and by default it already has a Default.aspx page added to it.</li>
</ul>
<p>Switch to Split View of the Default Page and drag and drop a Label, TextBox and Button Control on the interface such that it looks something like this.</p>
<div id="attachment_227" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-sample-default-page.jpg"><img class="size-medium wp-image-227" title="My First Website - Sample Default Page" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-sample-default-page-300x194.jpg" alt="My First Website - Sample Default Page" width="300" height="194" /></a><p class="wp-caption-text">My First Website - Sample Default Page</p></div>
<p>lets look at the declaration of these controls.</p>
<p>&lt;asp:Label ID=&#8221;lblmyLabel&#8221; runat=&#8221;server&#8221;&gt;&lt;/asp:Label&gt;<br />
&lt;asp:TextBox ID=&#8221;txtmyTextBox&#8221; runat=&#8221;server&#8221;&gt;&lt;/asp:TextBox&gt;<br />
&lt;asp:Button ID=&#8221;btnmyButton&#8221; runat=&#8221;server&#8221; Text=&#8221;Click&#8221; /&gt;</p>
<p>all of the ASP.NET Controls have the following characteristics</p>
<ul>
<li> Tag Element starting with <strong>asp:</strong> <em>( with the exception of HTML Controls )</em></li>
<li>Each tag (ASP.NET Control tag) has an attribute <strong>runat=&#8221;server&#8221;</strong> which indicates to the framework that this control needs to be rendered at the server side.<em> (HTML Controls can have this attribute only if you need to access it in the server side code)</em></li>
<li><strong>ID </strong>attribute in the declaration of the ASP.NET Control identifies it, once defined, these controls can be accessed on the server side with these IDs.(I have already given controls appropriate IDs)</li>
</ul>
<p>Now lets add a click event to the button we have on the page, to do that select the button and the look for <strong>Properties Panel</strong> on the right bottom of the VS Interface ( if you cannot see the properties panel, <strong>Press F4</strong>). everything you see in this panel are the properties of the control you have selected and you can modify them here. For now we are interested in adding a Click Event, Select  Events Tab in the properties panel.</p>
<div id="attachment_228" class="wp-caption aligncenter" style="width: 382px"><img class="size-full wp-image-228" title="My First Website - Properties Panel - Button Events" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-properties-panel-button-events.jpg" alt="My First Website - Properties Panel - Button Events" width="372" height="332" /><p class="wp-caption-text">My First Website - Properties Panel - Button Events</p></div>
<p>you can see there are number of Button events available, but by default no events is placed. To add an event, lets say Click Event, we need to double click the space in front of the Click Label, this will add a Button Click Event handler in the Code File of the Default.aspx. This is how your code-behind file for this page would look like with a Button Click Event Handler.</p>
<pre name="code" class="c#">using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnmyButton_Click(object sender, EventArgs e)
    {

    }
}</pre>
<p><strong>btnmyButton_Click </strong>Event will occur everytime when <strong>btnmyButton</strong> is clicked. now lets Append <strong>&#8220;Hello&#8221; </strong>to the Label (lblmyLabel) Text everytime this button is clicked.</p>
<pre name="code" class="c#">    protected void btnmyButton_Click(object sender, EventArgs e)
    {
        lblmyLabel.Text += "Hello ";
    }</pre>
<ul>
<li>Run (F5) the website and click on the Button more than one time and see what happens. (Note: for the very first time  a Message Box will appear once you Run (F5) your website asking whether to enable debugging or not, Press Yes/Ok)</li>
</ul>
<div id="attachment_233" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-button-click-event-handler-demonstration.jpg"><img class="size-medium wp-image-233" title="My First Website - Button Click Event Handler Demonstration" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-button-click-event-handler-demonstration-300x225.jpg" alt="My First Website - Button Click Event Handler Demonstration" width="300" height="225" /></a><p class="wp-caption-text">My First Website - Button Click Event Handler Demonstration</p></div>
<p>now this is how we can perform different kind of operations, for example manipulating certain information from a form to the database. similarly we have <strong>TextChanged </strong>Event available for the TextBox control, lets say we require that, whatever is written in the textbox is appended to the label whenever textbox loses focus, All we need to do is select mytxtTextBox control we dropped earlier on the page and add its TextChanged Event Handler like the way we added Button&#8217;s Click Event.</p>
<pre name="code" class="c#">using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnmyButton_Click(object sender, EventArgs e)
    {
        lblmyLabel.Text += "Hello ";
    }
    protected void txtmyTextBox_TextChanged(object sender, EventArgs e)
    {
        lblmyLabel.Text += txtmyTextBox.Text;
    }
}</pre>
<p>just the way on the click of the button there was a post back to the server so that text could be appended to the label, TextBoxes by default are set not to post back on any event, we have to explicitly enable post back by enabling <strong>AutoPostBack</strong> property of the<strong> txtmyTextBox.</strong></p>
<div id="attachment_236" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-properties-panel-autopostback-property.jpg"><img class="size-medium wp-image-236" title="My First Website - Properties Panel - AutoPostBack Property" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-properties-panel-autopostback-property-300x245.jpg" alt="My First Website - Properties Panel - AutoPostBack Property" width="300" height="245" /></a><p class="wp-caption-text">My First Website - Properties Panel - AutoPostBack Property</p></div>
<p>this will make the TextBox postback to the server on <strong>TextChanged </strong>Event.</p>
<ul>
<li>Now Run(F5) the website again</li>
<li>Enter some text in the textbox and click out side the textbox, this will make the textbox lose focus and subsequently will post back to the server and call the TextChanged Event Handler and our text will appended in the label above.</li>
</ul>
<div id="attachment_238" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-textboxs-textchanged-event-handler-demonstration.jpg"><img class="size-medium wp-image-238" title="My First Website - TextBox's TextChanged Event Handler Demonstration" src="http://www.dottostring.com/wp-content/uploads/2008/12/my-first-website-textboxs-textchanged-event-handler-demonstration-300x225.jpg" alt="My First Website - TextBox's TextChanged Event Handler Demonstration" width="300" height="225" /></a><p class="wp-caption-text">My First Website - TextBox&#39;s TextChanged Event Handler Demonstration</p></div>
<p>this brings us to the end of Part 03. In this part we learned How ASP.NET Controls and Event Handlers are used in ASP.NET Websites, in the upcoming parts we shall look into Controls in each Category in detail, discovering various properties and events associated with them.</p>
<ul>
<li>Thanks for Visiting, don&#8217;t forget to let us know how did this article helped you.</li>
<li><a href="http://www.dottostring.com/wp-content/uploads/2008/12/dottostring-aspnet-tutorialspart03.zip">Download Source Code  for Part 03</a></li>
<li>Cheers!</li>
</ul>
<p>Proceed to:</p>
<ul>
<li><a href="http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/" target="_self">ASP.NET Tutorials &#8211; [Part 04] ASP.NET 3.5 Controls and Event Handlers III<br />
	</a>
	</li>
</ul>
<p>Previous Parts:</p>
<ul>
<li><a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-1-a-peek-into-aspnet-and-net-framework-3_5/" target="_self">ASP.NET Tutorials &#8211; [Part 01] A peek into ASP.NET and .NET Framework 3.5</a></li>
<li><a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i/" target="_self">ASP.NET Tutorials &#8211; [Part 02] ASP.NET 3.5 Controls and Event Handlers I</a></li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F12%2Faspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii%2F';
  addthis_title  = 'ASP.NET+Tutorials+%26%238211%3B+%5BPart+03%5D+ASP.NET+3.5+Controls+and+Event+Handlers+II';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2008/12/aspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET Tutorials &#8211; [Part 02] ASP.NET 3.5 Controls and Event Handlers I</title>
		<link>http://www.dottostring.com/2008/12/aspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i/</link>
		<comments>http://www.dottostring.com/2008/12/aspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i/#comments</comments>
		<pubDate>Tue, 30 Dec 2008 17:18:48 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[.NET Controls]]></category>
		<category><![CDATA[.NET Framework 3.5]]></category>
		<category><![CDATA[AJAX Extensions]]></category>
		<category><![CDATA[ASP.NET 3.5]]></category>
		<category><![CDATA[ASP.NET 3.5 Controls]]></category>
		<category><![CDATA[ASP.NET Event Handlers]]></category>
		<category><![CDATA[Data Controls]]></category>
		<category><![CDATA[Event Handlers]]></category>
		<category><![CDATA[Login Controls]]></category>
		<category><![CDATA[Navigation Controls]]></category>
		<category><![CDATA[Standard Controls]]></category>
		<category><![CDATA[Validation Controls]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>
		<category><![CDATA[WebParts Controls]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=211</guid>
		<description><![CDATA[In part 1 we talked about ASP.NET and .NET Framework 3.5 in general and got accross some of the very basic concepts of .net technology. now we move on to ASP.NET Controls often termed as the heart of the .NET Framework.
There are around 70+ Controls in ASP.NET Framework and are categorized as follows.

Standard Controls
Data Controls
Validation [...]]]></description>
			<content:encoded><![CDATA[<p>In part 1 we talked about ASP.NET and .NET Framework 3.5 in general and got accross some of the very basic concepts of .net technology. now we move on to <strong>ASP.NET Controls</strong> often termed as the heart of the .NET Framework.</p>
<p>There are around <strong>70+ Controls in ASP.NET Framework</strong> and are categorized as follows.</p>
<ul>
<li>Standard Controls</li>
<li>Data Controls</li>
<li>Validation Controls</li>
<li>Navigation Controls</li>
<li>Login Controls</li>
<li>WebParts Controls</li>
<li>HTML Controls</li>
<li>AJAX Extentions</li>
</ul>
<p><strong>Standard Controls &#8211; </strong>as the name suggests this category contains all the basic controls in order to fullfil the web interface related requirements such as text boxes, hyperlinks, buttons, tables and many more.</p>
<p><strong>Data Controls &#8211; </strong>A number of useful data controls are available for the developer to easily communicate with database and efficiently display them to the end user. GridView, ObjectDataSource, Repeater are few of the most popular data controls.</p>
<p><strong>Validation Controls</strong> -  these controls come in very handy when we need to apply any sort of validations on the standard controls such as Required field validation on Textbox, Data Type validation, Regular Expression Match and many others.</p>
<p><strong>Navigation Controls &#8211; </strong>navigation controls make things very comfortable when it comes to manage navigation of your website for example generating SiteMaps, Menus and TreeView.</p>
<p><strong>Login Controls &#8211; </strong>these controls are there to be used whenever you need to implement security to your website, they enable you to display login, change password and registration forms.</p>
<p><strong>WebParts Controls &#8211; </strong> these controls enable end users to modify the content, appearance, and behavior of Web pages in the web browser itself.</p>
<p><strong>HTML Controls -</strong> these are standard HTML controls such as textboxes, anchor, checkboxes and any other HTML control you would know. it also gives the ability to convert any HTML tag into a server control.</p>
<p><strong>AJAX Extensions &#8211; </strong>this category contains some very helpful AJAX related controls which enables AJAX on  your pages magically ( well seems like magic ), for example if you want to change text of some label on the web page by a button&#8217;s click event using AJAX (without posting the entire page back) all you need to do is put that label and button in a UpdatePanel and that&#8217;s just about it!</p>
<p>we will learn about each of them in the detail in the later parts.</p>
<h3>Event Handlers</h3>
<p>Almost all of the ASP.NET controls provides one or more Events to support the idea of event driven web application. for example if you want that on a certain click of a button a text should change on the web page would require a Click Event of the Button to be raised when clicked and subsequently changing the text of the label placed somewhere on the page.</p>
<p>the code below demonstrates this example</p>
<pre name="code" class="html">&lt;%@ Page Language="C#" %&gt;

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

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

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "Button has been Clicked";
    }
&lt;/script&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head runat="server"&gt;
    &lt;title&gt;DotToString - My First Website&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;form id="form1" runat="server"&gt;
    &lt;div&gt;
        &lt;asp:Label ID="lblMessage" runat="server" Text="Click on the Button Below" &gt;&lt;/asp:Label&gt;&lt;br /&gt;
        &lt;asp:Button ID="btnSubmit" runat="server" Text="Click"
            onclick="btnSubmit_Click" /&gt;
    &lt;/div&gt;
    &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>In this example Two ASP.NET controls are used,  Label and Button. I have placed an onclick event which is handled by btnSubmit_Click Event Handler to change the text of the Label control.</p>
<p>In the part 3 I will demonstrate some samples codes (using Microsoft Visual Studio 2008) which will further elaborate the use of ASP.NET Controls and their Event Handlers.</p>
<p>keep visiting and don&#8217;t forget to leave feedback.</p>
<p>Cheers!</p>
<p>Proceed to:</p>
<ul>
<li><a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-03-aspnet-35-controls-and-event-handlers-ii/" target="_self">ASP.NET Tutorials &#8211; [Part 03] ASP.NET 3.5 Controls and Event Handlers II</a></li>
<li>
	<a href="http://www.dottostring.com/2009/02/aspnet-tutorials-part-04-aspnet-35-controls-and-event-handlers-iii/" target="_self">ASP.NET Tutorials &#8211; [Part 04] ASP.NET 3.5 Controls and Event Handlers III<br />
	</a>
	</li>
</ul>
<p>Previous Parts:</p>
<ul>
<li><a href="http://www.dottostring.com/2008/12/aspnet-tutorials-part-1-a-peek-into-aspnet-and-net-framework-3_5/" target="_self">ASP.NET Tutorials &#8211; [Part 01] A peek into ASP.NET and .NET Framework 3.5</a></li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F12%2Faspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i%2F';
  addthis_title  = 'ASP.NET+Tutorials+%26%238211%3B+%5BPart+02%5D+ASP.NET+3.5+Controls+and+Event+Handlers+I';
  addthis_pub    = 'erfaan';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://www.dottostring.com/2008/12/aspnet-tutorials-part-2-aspnet-35-controls-and-event-handlers-i/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
