<?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() &#187; C#.NET</title>
	<atom:link href="http://www.dottostring.com/category/cnet/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>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>3</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>
		<item>
		<title>How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET &#8211; How to Stop/Start the Ticker on Mouse Hover/Leave</title>
		<link>http://www.dottostring.com/2008/12/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave/</link>
		<comments>http://www.dottostring.com/2008/12/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 08:29:05 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[ManualResetEvent]]></category>
		<category><![CDATA[Message Smooth Scrolling]]></category>
		<category><![CDATA[Message Ticker]]></category>
		<category><![CDATA[Mouse Hover Leave Events]]></category>
		<category><![CDATA[Notification Bar]]></category>
		<category><![CDATA[Threading]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=166</guid>
		<description><![CDATA[With reference to my article How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET , I have been getting inquiries on how to handle certain mouse events. so in this post I will explain how you can make the scroller stop/start on mouse hover/leave events respectively.
before we [...]]]></description>
			<content:encoded><![CDATA[<p>With reference to my article <a href="http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/" target="_blank">How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET</a> , I have been getting inquiries on how to handle certain mouse events. so in this post I will explain how you can make the scroller stop/start on mouse hover/leave events respectively.</p>
<p>before we go ahead, I feel its important for you as reader to know that this is the third article in the chain.following are reference to the previous articles ( for those who are interested )</p>
<ol>
<li><a href="http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/" target="_blank">How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET</a> | <a href="http://www.dottostring.com/wp-content/uploads/2008/11/dottostringnotificationbarticker.zip">Download Source Code</a></li>
<li><a href="http://www.dottostring.com/2008/12/how-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net/" target="_blank">How to create (make a Windows Form act like) a Docking Window without a container in C#.NET</a> | <a href="http://www.dottostring.com/wp-content/uploads/2008/12/dottostringdockingwindow.zip">Download Source Code</a></li>
</ol>
<p> </p>
<p>moving on.</p>
<p>we have two labels which are working as a smooth vertically scrolling set of messages, this scroll effect is given by a Thread we created with the name <strong>BeginScroll, </strong>so in order to make the labels stop we have to some how make the infinite loop in the BeginScroll thread to stop and vice versa in case of start it again. for that to happen we are going to use a a concept straight out of the operating system textbook i.e. Semaphore/Mutex.</p>
<p>we have to develope a machanism that would allow us to use Signal/Wait strategy. For that .NET Framework has a handy feature called <strong>ManualResetEvent</strong>(<em>details of this is out of the scope of this article, so I would prefer you to look <a href="http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx" target="_blank">here </a>for further information ) </em></p>
<p>(You can use any of the source code mentioned in the above two articles,I will be using source code from the second article mentioned above in this example)</p>
<ul>
<li>Add the following two global declarations to the code (NotificationTiker.cs)</li>
</ul>
<pre name="code" class="c#">        public ManualResetEvent signalThread = new ManualResetEvent(false);
        private bool keepScrolling;
 </pre>
<ul>
<li>now add the MouseHover and MouseLeave events for the both the labels such that they should match the following code.</li>
</ul>
<pre name="code" class="c#">private void lblMessageOne_MouseHover(object sender, EventArgs e)
        {
            //Set KeepSrcolling variable to false so that the loop
            //in the thread terminates
            keepScrolling = false;
            //Reset Event of the ManualResetEvent will make WaitOne
            //Event in the BeginScroll Thread to block and effectively
            //stopping the scroll effect
            signalThread.Reset();
        }

        private void lblMessageOne_MouseLeave(object sender, EventArgs e)
        {
            //Set Event of the ManualResetEvent will release the blocked
            //Thread (blocked by the WaitOne Method)
            signalThread.Set();
        }

        private void lblMessageTwo_MouseHover(object sender, EventArgs e)
        {
            //Set KeepSrcolling variable to false so that the loop
            //in the thread terminates
            keepScrolling = false;
            //Reset Event of the ManualResetEvent will make WaitOne
            //Event in the BeginScroll Thread to block and effectively
            //stopping the scroll effect
            signalThread.Reset();
        }

        private void lblMessageTwo_MouseLeave(object sender, EventArgs e)
        {
            //Set Event of the ManualResetEvent will release the blocked
            //Thread (blocked by the WaitOne Method)
            signalThread.Set();
        }</pre>
<p>now after making some changes to the scroll function, it should contain the following code</p>
<pre name="code" class="c#">        private void BeginScroll()
        {
            //This variable will take label out of view
            int LabelHeight = -lblMessageOne.Height;
            //This variable will be used to assign out of view variable to bottom of the panel, to re-enter
            int PanelBottom = panel1.Height;
            bool firstEntry = true;
            while (true)
            {
                if (!firstEntry)
                    signalThread.WaitOne();
                keepScrolling = true;
                while (keepScrolling)
                {
                    firstEntry = false;
                    if (lblMessageOne.Location.Y == LabelHeight)
                    {
                        //when label one goes out of view, it is configured to re enter again
                        lblMessageOne.Location = new Point(lblMessageOne.Location.X, PanelBottom);
                    }
                    else
                    {
                        //Scrolling label by decrementing it y-axis location
                        int MessageOneY = lblMessageOne.Location.Y - 1;
                        lblMessageOne.Location = new Point(lblMessageOne.Location.X, MessageOneY);
                    }
                    if (lblMessageTwo.Location.Y == LabelHeight)
                    {
                        //when label one goes out of view, it is configured to re enter again
                        lblMessageTwo.Location = new Point(lblMessageTwo.Location.X, PanelBottom);
                    }
                    else
                    {
                        //Scrolling label by decrementing it y-axis location
                        int MessageTwoY = lblMessageTwo.Location.Y - 1;
                        lblMessageTwo.Location = new Point(lblMessageTwo.Location.X, MessageTwoY);
                    }
                    this.Refresh();
                    Thread.Sleep(50);
                }
            }
        }</pre>
<p> </p>
<ul>
<li>this is it, now Run(F5) the application and test the mouse over and leave events.</li>
<li>Cheers, dont forget to leave comments/feedback.</li>
<li>Download Source Code <a href="http://www.dottostring.com/wp-content/uploads/2008/12/dottostringnotificationbarticker-mouseevents.zip">Here</a>.</li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F12%2Fhow-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave%2F';
  addthis_title  = 'How+to+make+pop-up+%2F+Notification+bar+with+Message+Ticker+%28smooth+message+scroller%29+over+the+Task+Bar+in+C%23.NET+%26%238211%3B+How+to+Stop%2FStart+the+Ticker+on+Mouse+Hover%2FLeave';
  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/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to create(make a Windows Form act like) a Docking Window without a container in C#.NET</title>
		<link>http://www.dottostring.com/2008/12/how-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net/</link>
		<comments>http://www.dottostring.com/2008/12/how-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 19:29:37 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[Dock In]]></category>
		<category><![CDATA[Dock Out]]></category>
		<category><![CDATA[Docking Window]]></category>
		<category><![CDATA[Move Form]]></category>
		<category><![CDATA[Windows Application]]></category>
		<category><![CDATA[Windows Form]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=145</guid>
		<description><![CDATA[Time to share another interesting requirement I had to deal with when I was working on messaging application some time back(just in case if somebody is interested, I wrote about the Notification bar with smooth message/label scroller), which was how to make a Docking Window without a container.
Since there is no built in feature in [...]]]></description>
			<content:encoded><![CDATA[<p>Time to share another interesting requirement I had to deal with when I was working on messaging application some time back(just in case if somebody is interested, I wrote about the <a href="http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/" target="_blank">Notification bar with smooth message/label scroller</a>), which was how to make a Docking Window without a container.</p>
<p>Since there is no built in feature in the .NET Framework 2.0 to facilitate this, I decided to yet again  tinkle up with the dynamic positioning of the form on the screen. All I needed was a windows form which could act like Docking Window on the Right of the screen.</p>
<p>I will integrate this piece in the previous application I buit on <a href="http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/" target="_blank"><em>How to make pop-up / Notification bar with Merssage Ticker (smooth message scroller) over the Task Bar in C#.NET</em></a></p>
<ul>
<li>Create a new Windows application (C#.NET) or Download the application I mentioned above.</li>
<li>Add a new windows form with the name &#8220;DockingWindow&#8221;</li>
<li>Re-Size it such that it looks like a Docking Window ( set <strong>Size </strong>310, 450 ), also set <strong>ControlBox </strong>Property to False and <strong>FormBorderStyle </strong>to None. This will remove the windows normal controls to Close,Minimize and Restore.</li>
<li>Now Add a Panel (ID: pVisiblePart) and set it <strong>Dock</strong> Property to Left.</li>
</ul>
<div id="attachment_148" class="wp-caption aligncenter" style="width: 509px"><img class="size-full wp-image-148" title="An Illustration of Initial Version of Docking Window" src="http://www.dottostring.com/wp-content/uploads/2008/12/initialdockingwindow.jpg" alt="An Illustration of Initial Version of Docking Window" width="499" height="486" /><p class="wp-caption-text">An Illustration of Initial Version of Docking Window</p></div>
<p>Since Docking Window is required to stick to the right side of the desktop and also should resize dynamically such that it matches the height of the working area. Also we would require a Button which will allow us to Dock(&gt;&gt;)/UnDock(&lt;&lt;) the Window.</p>
<h4>Dock (&gt;&gt;)</h4>
<p>This would require us to set the Location of the Docking Window such that only the panel (pVisiblePart) is visible, with the Button Available to UnDock the Window</p>
<h4>Un-Dock(&lt;&lt;)</h4>
<p>This would require us to set the Location back to normal but still sticking to the right side of the screen, with a Button Available to Dock again.</p>
<p>so for the code should look like this.</p>
<pre name="code" class="c#">using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace _DotToString_NotificationBarTicker
{
    public partial class DockingWindow : Form
    {
        public DockingWindow()
        {
            InitializeComponent();
            configureThis();
        }
        ///
        /// Gets The Screen Width Available for Work
        ///
        /// Working Width Area
        private int getScreenWidth()
        {
            Rectangle recWorkingArea = new Rectangle();
            recWorkingArea = Screen.PrimaryScreen.WorkingArea;
            return recWorkingArea.Width;
        }
        ///
        /// Gets The Screen Height Available for Work
        ///
        /// Working Height Area
        private int getScreenHeight()
        {
            Rectangle recWorkingArea = new Rectangle();
            recWorkingArea = Screen.PrimaryScreen.WorkingArea;
            return recWorkingArea.Height;
        }
        ///
        /// Initialize the Docking Window Start Location
        ///
        private void configureThis()
        {
            //Dynamically resizing the form to match the height available on the screen
            this.Size = new Size(this.Width, getScreenHeight());
            //Calculating the Horizontal Location of the Form (Docking Window)
            //such that only the panel having the Docking Window's Navigation Control
            //will be visible
            int EndX = getScreenWidth() - pVisiblePart.Width;
            this.Location = new System.Drawing.Point(EndX, 0);
            //Setting the Text of the Button which will act at the Navigation for Docking Window
            this.btnDockUnDock.Text = "&lt;&lt;";
        }
    }
}</pre>
<p>I have documented through the code so that it helps you understand various code statements.</p>
<ul>
<li>Now Run(F5) your project</li>
<li>you should be able to see the following</li>
</ul>
<div id="attachment_157" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/docking-window-screenshot.jpg"><img class="size-medium wp-image-157" title="An Illustration of Initial Docking Window" src="http://www.dottostring.com/wp-content/uploads/2008/12/docking-window-screenshot-300x187.jpg" alt="An Illustration of Initial Docking Window" width="300" height="187" /></a><p class="wp-caption-text">An Illustration of Initial Docking Window</p></div>
<ul>
<li>now we just need to take care of two things,
<ul>
<li>how to Un-Dock the Docking Window?</li>
<li>how to Dock the Docking Window?</li>
</ul>
</li>
</ul>
<h4>How to Un-Dock the Docking Window?</h4>
<p>on the click event of the button we will now change the location of the window such that it gives an effect of coming out from the left.</p>
<pre name="code" class="c#">        private void btnDockUnDock_Click(object sender, EventArgs e)
        {
            if (btnDockUnDock.Text.Trim().Equals("&lt;&lt;"))
                DockOut();
            else
                DockIn();
        }
        ///
        /// Docking Window is brought to the front
        ///
        public void DockOut()
        {
            //Starting Location of the Docking Window
            int StartX = this.Location.X;
            //Calculating the final X Coordinate at which the docking window should
            //settle in order to be completely visible
            int EndX = getScreenWidth() - this.Width;
            //This loops does the trick for us, this will effectively simulate the
            //coming out effect to the docking window, eventually making the window
            //completely visible
            for (int i = StartX; i &gt;= EndX; i--)
            {
                this.Location = new System.Drawing.Point(i, 0);
            }
            //Setting the final location (ensuring the final location)
            this.Location = new System.Drawing.Point(EndX, 0);
            this.btnDockUnDock.Text = "&gt;&gt;";
        }
        ///
        /// Docking Window is Docked Back In
        ///
        public void DockIn()
        {
            //Getting the Start Location for the loop
            int StartX = this.Location.X;
            //Calculation the final x coordinate for the loop to finish
            int EndX = getScreenWidth() - pVisiblePart.Width;
            //This is loop will dock the window back in
            for (int i = StartX; i &lt;= EndX; i++)
            {
                this.Location = new System.Drawing.Point(i, 0);
            }
            this.Location = new System.Drawing.Point(EndX, 0);
            this.btnDockUnDock.Text = "&lt;&lt;";
        }</pre>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.dottostring.com/wp-content/uploads/2008/12/docking-window-screenshot-2.jpg"><img class="size-medium wp-image-161" title="An Illustration of Docking Window in Visible Mode: Dock Out" src="http://www.dottostring.com/wp-content/uploads/2008/12/docking-window-screenshot-2-300x187.jpg" alt="An Illustration of Docking Window in Visible Mode: Dock Out" width="300" height="187" /></a><p class="wp-caption-text">An Illustration of Docking Window in Visible Mode: Dock Out</p></div>
<ul>
<li>BINGO!  thats just about it, Docking Window is there to be used.</li>
<li>you can continue adding contents to the form&#8217;s working area just like a common form.</li>
<li>Cheers, don&#8217;t forget to leave in your comments/feedback.</li>
<li>Download the complete source code <a href="http://www.dottostring.com/wp-content/uploads/2008/12/dottostringdockingwindow.zip">here</a></li>
</ul>
<p>Related Articles:</p>
<ul>
<li><a href="http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/" target="_blank">How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET</a></li>
<li><a href="http://www.dottostring.com/2008/12/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave/" target="_blank">How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET &#8211; How to Stop/Start the Ticker on Mouse Hover/Leave</a></li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F12%2Fhow-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net%2F';
  addthis_title  = 'How+to+create%28make+a+Windows+Form+act+like%29+a+Docking+Window+without+a+container+in+C%23.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/2008/12/how-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using ASP.NET TextBox as ExtJs form TextField with clientside validation ubobtrusively</title>
		<link>http://www.dottostring.com/2008/11/using-aspnet-textbox-as-extjs-form-textfield-with-clientside-validation-ubobtrusively/</link>
		<comments>http://www.dottostring.com/2008/11/using-aspnet-textbox-as-extjs-form-textfield-with-clientside-validation-ubobtrusively/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 21:58:50 +0000</pubDate>
		<dc:creator>Irfan</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[ExtJs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[TextBox]]></category>
		<category><![CDATA[TextField]]></category>
		<category><![CDATA[unobtrusive]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=126</guid>
		<description><![CDATA[This mini tutorial will enable you to use the default functionality of ASP.NET TextBox and ASP.NET Button with client side validation using ExtJs.
Lets start with making a ASP.NET page with 2 TextBox and 1 Button.

&#60;div class="Form"&#62;
	&#60;fieldset class="Form"&#62;
		&#60;asp:Label ID="Label1" AssociatedControlID="TextBox1" runat="server" Text="Text Field 1" CssClass="lblTextField"&#62;&#60;/asp:Label&#62;
		&#60;asp:TextBox ID="TextBox1" runat="server" CssClass="textField"&#62;&#60;/asp:TextBox&#62;

		&#60;br /&#62;
		&#60;asp:Label ID="Label2" AssociatedControlID="TextBox2" runat="server" Text="Text Field 2" CssClass="lblTextField"&#62;&#60;/asp:Label&#62;
		&#60;asp:TextBox [...]]]></description>
			<content:encoded><![CDATA[<p>This mini tutorial will enable you to use the default functionality of ASP.NET TextBox and ASP.NET Button with client side validation using ExtJs.</p>
<p>Lets start with making a ASP.NET page with 2 TextBox and 1 Button.</p>
<pre name="code" class="html">
&lt;div class="Form"&gt;
	&lt;fieldset class="Form"&gt;
		&lt;asp:Label ID="Label1" AssociatedControlID="TextBox1" runat="server" Text="Text Field 1" CssClass="lblTextField"&gt;&lt;/asp:Label&gt;
		&lt;asp:TextBox ID="TextBox1" runat="server" CssClass="textField"&gt;&lt;/asp:TextBox&gt;

		&lt;br /&gt;
		&lt;asp:Label ID="Label2" AssociatedControlID="TextBox2" runat="server" Text="Text Field 2" CssClass="lblTextField"&gt;&lt;/asp:Label&gt;
		&lt;asp:TextBox ID="TextBox2" runat="server" CssClass="textField"&gt;&lt;/asp:TextBox&gt;

		&lt;br /&gt;
		&lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
	&lt;/fieldset&gt;
&lt;/div&gt;
</pre>
<p>We want to use unobtrusive javascript. So we will start with writing our code within Ext.onReady event. This event ensures that all DOM has been loaded and this is faster than window.onload event.</p>
<pre name="code" class="js">
        Ext.onReady(function(){
                // write your code here
        });
</pre>
<p>Now use the functionality of DomQuery to find all text boxes having a particular class on our page. DomQuery helps you in finding element using CSS3 selectors. ExtJs has optimized this for each browser so this is faster and convenient than regular techniques.</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            // Get an array of all input text fields using DomQuery
            var textBoxes = Ext.DomQuery.select("input[class=textField]");
        });
</pre>
<p>Above code returns us an array of all ASP.NET TextBoxes having class textField. We loop through each of these TextBoxes and make an Ext TextField against each ASP.NET TextBox.</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            // Get an array of all input text fields using DomQuery
            var textBoxes = Ext.DomQuery.select("input[class=textField]");

            // An array to keep track of all ExtJs Text Fields
            var ExtTextFields = Array();

            // Now loop through each element and make it Ext TextField
            Ext.each(textBoxes,function(item,index,allItems){
                ExtTextFields[index] = new Ext.form.TextField();
            });
        });
</pre>
<p>But we dont want to make a separate TextField. We want to convert ASP.NET field into ExtJs TextField without changing its default behavior. This can be archived by using configuration settings of TextField.</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            // Get an array of all input text fields using DomQuery
            var textBoxes = Ext.DomQuery.select("input[class=textField]");

            // An array to keep track of all ExtJs Text Fields
            var ExtTextFields = Array();

            // Now loop through each element and make it Ext TextField
            Ext.each(textBoxes,function(item,index,allItems){
                ExtTextFields[index] = new Ext.form.TextField({
                     allowBlank : false,
                     applyTo : item
                });
            });
        });
</pre>
<p>Now we have perfectly working ASP.NET TextBoxes which have client side validation of required field using ExtJs. Lets add some more functionality to this. Now we want to disable the ASP.NET button if the TextBoxes are left empty and enable it if all the TextBoxes are filled in. This functionality will be archived by writing handlers for ExtJs TextField custom events onValid and onInvalid.</p>
<pre name="code" class="js">
        Ext.onReady(function(){
            // Get an array of all input text fields using DomQuery
            var textBoxes = Ext.DomQuery.select("input[class=textField]");

            // An array to keep track of all ExtJs Text Fields
            var ExtTextFields = Array();

            // Now loop through each element and make it Ext TextField
            Ext.each(textBoxes,function(item,index,allItems){
                ExtTextFields[index] = new Ext.form.TextField({
                     allowBlank : false,
                     applyTo : item
                });

                // add an event to disable the submit button when there is no text in the field
                ExtTextFields[index].on("invalid",function(evt,target,opts){
                    Ext.get("Button1").set({disabled:true});
                });

                // add an event to enable the submit button when both fields have some value
                ExtTextFields[index].on("valid",function(evt,target,opts){
                    var flagDisableButton = false;
                    Ext.each(ExtTextFields,function(t,i,a){
                        // if any of the field is not valid, set flag to false
                        if(t.isValid() == false) {
                            flagDisableButton = true;
                        }
                    });
                    Ext.get("Button1").dom.disabled = flagDisableButton;
                });

            });
        });
</pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F11%2Fusing-aspnet-textbox-as-extjs-form-textfield-with-clientside-validation-ubobtrusively%2F';
  addthis_title  = 'Using+ASP.NET+TextBox+as+ExtJs+form+TextField+with+clientside+validation+ubobtrusively';
  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/11/using-aspnet-textbox-as-extjs-form-textfield-with-clientside-validation-ubobtrusively/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET</title>
		<link>http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/</link>
		<comments>http://www.dottostring.com/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 20:53:10 +0000</pubDate>
		<dc:creator>babarjehangir</dc:creator>
				<category><![CDATA[C#.NET]]></category>
		<category><![CDATA[Windows Forms]]></category>
		<category><![CDATA[C#.NET Scroller Ticker Message Labels Smooth]]></category>

		<guid isPermaLink="false">http://www.dottostring.com/?p=97</guid>
		<description><![CDATA[few weeks ago I had to work on an application that had a client piece which was required to act like the a one-way messenger e.g. Supervisors wanted to send in messages to their sub ordinates. one of the requirements was whenever a new message arrived, a notification bar should pop-up over the task bar [...]]]></description>
			<content:encoded><![CDATA[<p>few weeks ago I had to work on an application that had a client piece which was required to act like the a one-way messenger e.g. Supervisors wanted to send in messages to their sub ordinates. one of the requirements was whenever a new message arrived, a notification bar should pop-up over the task bar with all the new messages appearing in a ticker fashion ( also messages should scroll smoothly).</p>
<p>There is no .net control available to achieve this. so I searched the internet in hope to get hold of some (free) third party custom controls, but dint find anything of significant help, all I found was how to make characters within the label text scroll horizontally. so I decided to make something of my own.</p>
<p>problems I had to cope with here were:</p>
<ul>
<li>how to make a windows form act as a pop-up/Notification bar over the task bar?</li>
<li>how to implement message ticker (i.e. smooth scrolling of the messages on the pop-up/Notification bar)?</li>
</ul>
<h5>how to make a windows form act as a pop-up/Notification bar over the task bar?</h5>
<ul>
<li>As always, we begin by creating a new Windows Application (C#.NET)</li>
</ul>
<div id="attachment_99" class="wp-caption aligncenter" style="width: 510px"><img class="size-full wp-image-99" title="An illustration of creating a new windows application (C#.NET)" src="http://www.dottostring.com/wp-content/uploads/2008/11/notification-tickernew-project.jpg" alt="An illustration of creating a new windows application (C#.NET)" width="500" height="363" /><p class="wp-caption-text">An illustration of creating a new windows application (C#.NET)</p></div>
<ul>
<li>now by quickly doing the following:
<ul>
<li>Rename the Form1.cs with something meaningful, such as &#8220;NotificationTicker.cs&#8221;, Press &#8220;Yes&#8221; when it asks for renaming reference content.</li>
<li>Re size the form such that it looks like a notification bar.</li>
<li>Drop in a group box from the toolbox and re size it to stretch towards the boundaries.</li>
<li>Drop in a label in the group box area and assign some dummy text to it.</li>
<li>Set ControlBox Property of the Form to false.</li>
<li>Set ShowInTaskbar Property of the Form to false.</li>
</ul>
<p>we get</li>
</ul>
<div id="attachment_106" class="wp-caption aligncenter" style="width: 510px"><img class="size-full wp-image-106" title="Notification Ticker Initial Form Sample" src="http://www.dottostring.com/wp-content/uploads/2008/11/notification-tickernotification-tiker-form.jpg" alt="Notification Ticker Initial Form Sample" width="500" height="350" /><p class="wp-caption-text">Notification Ticker Initial Form Sample</p></div>
<ul>
<li>verify that everything is working fine by compiling and running the application (F5)</li>
<li>Width of the form should be equal to the width of the user screen, this is simple, all we need here is to find out the working area of the client machine.</li>
<li>Working Area of the Client Machine is the space on screen available for the Forms to appear (excluding Taskbars, Docked Windows e.t.c).</li>
<li>we get this space in the form of rectangle.</li>
</ul>
<pre name="code" class="c#">Rectangle recWorkingArea = new Rectangle();
recWorkingArea = Screen.PrimaryScreen.WorkingArea;</pre>
<ul>
<li>by using the working area and a bit of mathematics we can get what we want.</li>
</ul>
<pre name="code" class="c#">        private int getScreenWidth()
        {
            Rectangle recWorkingArea = new Rectangle();
            recWorkingArea = Screen.PrimaryScreen.WorkingArea;
            return recWorkingArea.Width;
        }
        private int getScreenHeight()
        {
            Rectangle recWorkingArea = new Rectangle();
            recWorkingArea = Screen.PrimaryScreen.WorkingArea;
            return recWorkingArea.Height;
        }
        private void FitToScreen()
        {
            this.Size = new Size(getScreenWidth(), this.FormHeight);
            this.Location = new System.Drawing.Point(0, this.Location.Y);
        }</pre>
<ul>
<li>FitToScreen() when called will span the form to the width of the user screen.</li>
<li>Now we need to re size the group box as well, that&#8217;s also done with a bit of simple mathematics</li>
</ul>
<pre name="code" class="c#">private void SetGroupBox()
{
    int diff = (this.Location.X + this.Width) - (this.gbNotificationCenter.Location.X + gbNotificationCenter.Width);
    this.gbNotificationCenter.Size = new Size((getScreenWidth() - diff) - this.gbNotificationCenter.Location.X, this.gbNotificationCenter.Height);
}</pre>
<ul>
<li>call these functions ( FitToScreen and SetGroupBox ) in the below sequence in the form constructor and then Run(F5) your application</li>
</ul>
<pre name="code" class="c#">        public NotificationTicker()
        {
            InitializeComponent();
            SetGroupBox();
            FitToScreen();
        }</pre>
<ul>
<li>if you have done everything as right, you should see a form with the same height (as in the design time) but with a width equal to the your screen width.</li>
</ul>
<p>now the pop-up part, this requires a bit of tinkling with the Location.Y ( Top-Left ) of the form. if we can somehow place the form initially at the height of the working area and then start decrementing it till Location.Y(of the form) + Height(of the form) equals Height of the working area, this would do the trick. Also note that all of this code would be written in Activated Event of the form, so that whenever the form is activated this form gives an effect of pop-up notification bar.</p>
<p>define a variable FormHeight and initialize it to a static value of the form height shown at the design time. because of at the runtime Height (of the form) becomes (form height (at design time) + ControlBox height).</p>
<pre name="code" class="c#">private void NotificationTicker_Activated(object sender, EventArgs e)
{
    //firsttime is a global boolean variable initialized to true
    if (firsttime)
    {
        //setting this to false, right away. because activated is called again whenever
        //form gets the focus.
        firsttime = false;
        //Initializing the form to the bottom of the working area ( out of visible area )
        this.Location = new System.Drawing.Point(0, getScreenHeight());
        this.Refresh();
        //Read about the below line in the next section, where we will enable it
        //InitiateScrollingThread();
        //calculating the seed, so that opacity increases from 0% to 100% during the course of popping up.
        double opacityIncreaseSeed = 100.0 / (Convert.ToDouble(this.FormHeight) * 100.0);
        //Starting Index for the loop
        int ScreenHeight = getScreenHeight();
        //End Index for the loop to stop
        int StartY = getScreenHeight() - this.FormHeight;
        for (int i = ScreenHeight; i &gt;= StartY; i--)
        {
            //Increasing opacity gradually
            this.Opacity = this.Opacity + opacityIncreaseSeed;
            //updating the location to give the move up effect
            this.Location = new System.Drawing.Point(0, i);
            this.Refresh();
            //to put some delay.
            Thread.Sleep(10);
        }
        //finally setting Opacity of the form to 100%
        this.Opacity = 1.0;
    }
}</pre>
<ul>
<li>Run(F5) the application and there you have a smooth and graceful pop-up notification bar coming out over the taskbar.</li>
<li><a href="http://www.dottostring.com/wp-content/uploads/2008/11/dottostringnotificationbar.zip">Download</a> Source Code up till here</li>
</ul>
<p>moving on to the second problem</p>
<h5>how to implement message ticker (i.e. smooth scrolling of the messages on the pop-up/Notification bar)?</h5>
<p>This is a bit tricky, but the idea is pretty simple. if you think you can implement smooth scrolling / ticker with two labels potentially. All you need to do is move one label out of the view and simultaneously moving the other one into view, assign a new message to the label that went out of the view and start to move it into the view again while the other one goes out of the view so on and so forth.</p>
<p>to accomplish this we need to drop in a panel and two labels, NOTE: Labels should be placed such that, they are inside the panel.</p>
<div id="attachment_114" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.dottostring.com/wp-content/uploads/2008/11/notification-tickernotification-ticker-with-two-labels1.jpg"><img class="size-full wp-image-114" title="Demonstration of Notification Ticker with Two labels" src="http://www.dottostring.com/wp-content/uploads/2008/11/notification-tickernotification-ticker-with-two-labels1.jpg" alt="Demonstration of Notification Ticker with Two labels" width="500" height="352" /></a><p class="wp-caption-text">Demonstration of Notification Ticker with Two labels</p></div>
<p>here we need to understand that scrolling will be a continuous event and therefore we cannot have this method in the same application thread. we need to create a separate thread to handle the scrolling.</p>
<p>all of this is handled by the following two functions</p>
<pre class="c#" name="code">private void InitiateScrollingThread()
{
    //Bottom of the Panel, will be used for hiding one of the two labels
    int PanelBottom = panel1.Height;
    //Setting the second label below the panel (effectively taking it out of view)
    lblMessageTwo.Location = new Point(lblMessageTwo.Location.X, PanelBottom);
    // we have to set this to false, otherwise we wont able to update the location
    // of the labels from the scrolling thread.
    System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
    //Initializing the scrollerThread(defined globally, Thread scrollerThread)
    scrollerThread = new Thread(BeginScroll);
    //Starting the BeginScroll Function at a separate thread
    scrollerThread.Start();
}
private void BeginScroll()
{
    //This variable will take label out of view
    int LabelHeight = -lblMessageOne.Height;
    //This variable will be used to assign out of view variable to bottom of the panel, to re-enter
    int PanelBottom = panel1.Height;
    while (true)
    {
        if (lblMessageOne.Location.Y == LabelHeight)
        {
            //when label one goes out of view, it is configured to re enter again
            lblMessageOne.Location = new Point(lblMessageOne.Location.X, PanelBottom);
        }
        else
        {
            //Scrolling label by decrementing it y-axis location
            int MessageOneY = lblMessageOne.Location.Y - 1;
            lblMessageOne.Location = new Point(lblMessageOne.Location.X, MessageOneY);
        }
        if (lblMessageTwo.Location.Y == LabelHeight)
        {
            //when label one goes out of view, it is configured to re enter again
            lblMessageTwo.Location = new Point(lblMessageTwo.Location.X, PanelBottom);
        }
        else
        {
            //Scrolling label by decrementing it y-axis location
            int MessageTwoY = lblMessageTwo.Location.Y - 1;
            lblMessageTwo.Location = new Point(lblMessageTwo.Location.X, MessageTwoY);
        }
        this.Refresh();
        Thread.Sleep(50);

    }
}</pre>
<ul>
<li>make a call to InitiateScrollingThread() funcation in the Activated Event defined above (in the if condition after setting the Location of the form)</li>
<li>and that&#8217;s it, we are done.</li>
<li>Run (F5) the application and the see smooth pop-up notification bar over the taskbar and then the smoothly scrolling messages.</li>
<li><a href="http://www.dottostring.com/wp-content/uploads/2008/11/dottostringnotificationbarticker.zip">Download</a> Source Code Here</li>
<li>Cheers (don&#8217;t forget to leave your feedback/concerns)</li>
</ul>
<p>Related Articles:</p>
<ul>
<li><a href="http://www.dottostring.com/2008/12/how-to-create-make-a-windows-form-act-like-a-docking-window-without-a-container-in-c-sharp-net/" target="_blank">How to create (make a Windows Form act like) a Docking Window without a container in C#.NET</a></li>
<li><a href="http://www.dottostring.com/2008/12/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-c-sharp-net-how-to-stopstart-the-ticker-on-mouse-hoverleave/" target="_blank">How to make pop-up / Notification bar with Message Ticker (smooth message scroller) over the Task Bar in C#.NET &#8211; How to Stop/Start the Ticker on Mouse Hover/Leave</a></li>
</ul>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.dottostring.com%2F2008%2F11%2Fhow-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet%2F';
  addthis_title  = 'How+to+make+pop-up+%2F+Notification+bar+with+Message+Ticker+%28smooth+message+scroller%29+over+the+Task+Bar+in+C%23.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/2008/11/how-to-make-pop-up-notification-bar-with-message-ticker-smooth-message-scroller-over-the-task-bar-in-cnet/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
