<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Diaa Arfan</title><link>http://weblogs.asp.net:80/diaaarfan/</link><description>Laziness, Impatience, and Hubris</description><item><title>Page.GetPostBackEventReference Method</title><link>http://weblogs.asp.net:80/diaaarfan/page-getpostbackeventreference-method</link><description>&lt;p&gt;Page.GetPostBackEventReference returns a string that can be used in a client event to cause postback to the server. The reference string is defined by the specified Control object ex: Page.GetPostBackEventReference(Control)&lt;/p&gt;  &lt;p&gt;This will allow adding postback to any HTML Element. &lt;/p&gt;  &lt;p&gt;It is very helpful in case you are mixing the use between ajax webservice calls and update panels. It will allow you to refresh/update any update panel from any HTML element on the page by adding postback of a button inside the update panel to the HTML element.&lt;/p&gt;  &lt;p&gt;example:&lt;/p&gt;  &lt;p&gt;&amp;lt;a onclick=&amp;quot;&amp;lt;%=&lt;strong&gt;Page.GetPostBackEventReference&lt;/strong&gt;(ButtonContol)%&amp;gt;;&amp;quot;&amp;gt;Refresh&amp;lt;/a&amp;gt;&lt;/p&gt;  &lt;p&gt;the ButtonControl must be a server side control button placed inside the update panel or specified as trigger for the update panel. &lt;/p&gt;</description><pubDate>Thu, 28 Aug 2008 23:30:34 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/page-getpostbackeventreference-method</guid><category>.NET</category><category>AJAX</category><category>ASP.NET</category><category>C#</category><category>General Software Development</category><category>Javascript OOP</category></item><item><title>Azalea : .net Terrarium Plant - Survivor</title><link>http://weblogs.asp.net:80/diaaarfan/azalea-net-terrarium-plant-survivor</link><description>&lt;p&gt;I read lately a blog post for &lt;a href="http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx" mce_href="http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx" target="_blank"&gt;Bil Simser reintroducing the .net Terrarium project (2.0)&lt;/a&gt;. For those who don't know what is this project about check out these links:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx" title="http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx" mce_href="http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx"&gt;http://weblogs.asp.net/bsimser/archive/2008/07/16/reintroducing-terrarium-now-with-2-0-goodness.aspx&lt;/a&gt; (Bil reintroducing the project)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://terrariumserver.com/" title="http://terrariumserver.com/" mce_href="http://terrariumserver.com/"&gt;http://terrariumserver.com/&lt;/a&gt; (game server)&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.codeplex.com/terrarium2" title="http://www.codeplex.com/terrarium2" mce_href="http://www.codeplex.com/terrarium2"&gt;http://www.codeplex.com/terrarium2&lt;/a&gt; (the project)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Terrarium .net was developed by the .NET Framework team in the .NET Framework 1.0 timeframe and was used initially as an internal test application. It is also a great opportunity to learn .net for beginners, but also a great opportunity for those who like strategy games. &lt;/p&gt;  &lt;p&gt;"In Terrarium, you can create herbivores, carnivores, or plants and then introduce them into a peer-to-peer, networked ecosystem where they complete for survival. Terrarium demonstrates some of the features of the .NET Framework, including Windows Forms integration with DirectX®; XML Web services; support for peer-to-peer networking; support for multiple programming languages; the capability to update smart client, or Windows-based, applications via a remote Web server; and the evidence-based and code access security infrastructure." (&lt;a href="http://www.codeplex.com/terrarium2" mce_href="http://www.codeplex.com/terrarium2" target="_blank"&gt;codeplex&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;Interesting right? But to get started coding your creature you will at least need a plant to serve as food for herbivores and I just created one. I called it Azalea, and it seems to be a survivor since I tried it with the &lt;a href="http://terrariumserver.com/documentation/samples/default.aspx" mce_href="http://terrariumserver.com/documentation/samples/default.aspx" target="_blank"&gt;3 example species of herbivores&lt;/a&gt;, and it survived them all.&lt;/p&gt;  &lt;p&gt;Here's the code for the plant:&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;h6&gt;using System;&lt;/h6&gt;  &lt;h6&gt;using System.Collections;&lt;/h6&gt;  &lt;h6&gt;using System.Drawing;&lt;/h6&gt;  &lt;h6&gt;using System.IO;&lt;/h6&gt;  &lt;h6&gt;using OrganismBase; &lt;/h6&gt;  &lt;h6&gt;[assembly: OrganismClass("Azalea.myAzalea")]&lt;/h6&gt;  &lt;h6&gt;[assembly: AuthorInformation("Diaa Arfan", "darfan@xplorium.com")] &lt;/h6&gt;  &lt;h6&gt;namespace Azalea&lt;/h6&gt;  &lt;h6&gt;{&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region Attributes&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [Carnivore(false)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [MatureSize(48)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [SeedSpreadDistance(10)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [PlantSkin(PlantSkinFamily.Plant)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [MarkingColor(KnownColor.Yellow)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [MaximumEnergyPoints(50)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [EatingSpeedPointsAttribute(50)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [AttackDamagePointsAttribute(0)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [DefendDamagePointsAttribute(0)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [MaximumSpeedPointsAttribute(0)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [CamouflagePointsAttribute(0)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [EyesightPointsAttribute(0)]&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public class myAzalea : Plant&lt;/h6&gt;    &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp; &lt;br&gt;&lt;/h6&gt;&lt;br&gt;&lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region Init&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override void Initialize()&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteTrace("new init for Azalea..");&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&lt;/h6&gt;  &lt;h6&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/h6&gt;  &lt;h6&gt;}&lt;/h6&gt;  &lt;p&gt;&lt;b&gt;&lt;u&gt;What would be interesting for your creatures is to have:&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;b&gt;path finding algorithm that considers plants, enemies and friends located in the perimeter.&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;genetic information transfer and mutation in behaviors from a generation to another.&lt;/b&gt;&lt;/li&gt;    &lt;li&gt;&lt;b&gt;group coordination, and maybe roles coordination between different friendly species.&lt;/b&gt;&lt;/li&gt; &lt;/ul&gt;</description><pubDate>Thu, 28 Aug 2008 22:33:00 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/azalea-net-terrarium-plant-survivor</guid><category>.NET</category><category>C#</category><category>General Software Development</category></item><item><title>Z-index dilemma in IE</title><link>http://weblogs.asp.net:80/diaaarfan/z-index-dilemma-in-ie</link><description>&lt;p&gt;&lt;a href="https://aspblogs.blob.core.windows.net/media/diaaarfan/WindowsLiveWriter/ZindexdilemmainIE_A47/NormalLayers.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="183" alt="NormalLayers" src="https://aspblogs.blob.core.windows.net/media/diaaarfan/WindowsLiveWriter/ZindexdilemmainIE_A47/NormalLayers_thumb.png" width="260" align="right" border="0" /&gt;&lt;/a&gt;Z-index is generally used to organize layers appearance in HTML documents, layers with higher z-index value will appear on top. This fact describe general behavior of layers on browsers like SAFARI, IE, and FIREFOX. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The problem is when you got nested layers rendering will be different on distinct browsers specifically on IE. In this case IE won&amp;#8217;t allow child layers to have z-index higher than their parent. Therefore in IE you will only be able to control layers order within their parent container.&lt;/p&gt;  &lt;p&gt;&lt;a href="https://aspblogs.blob.core.windows.net/media/diaaarfan/WindowsLiveWriter/ZindexdilemmainIE_A47/LayersIE.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="221" alt="LayersIE" src="https://aspblogs.blob.core.windows.net/media/diaaarfan/WindowsLiveWriter/ZindexdilemmainIE_A47/LayersIE_thumb.png" width="260" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the last example LayerB is not rendered on top of LayerA on IE because its parent container z-index is smaller than LayerA z-index although its z-index is higher than LayerA's z-index.&lt;/p&gt;  &lt;p&gt;The best approach to bypass this difference in browsers behavior&amp;#160; is to organize your HTML page structure to have popups layers that you want to control their order in the same container.&lt;/p&gt;</description><pubDate>Thu, 28 Aug 2008 21:51:49 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/z-index-dilemma-in-ie</guid><category>General Software Development</category><category>Javascript OOP</category></item><item><title>JQuery.makeMyLifeEasier()</title><link>http://weblogs.asp.net:80/diaaarfan/jquery-makemylifeeasier</link><description>&lt;p&gt;For all those who didn't use JQuery yet, you must know that JQuery can make your life easier. The javascript library allows you to do a lot in few lines of code, it also has a lot of functions that are so handful. I won't list them but I will point its official website &lt;a href="http://jquery.com"&gt;http://jquery.com&lt;/a&gt; and another wiki visual site &lt;a href="http://visualjquery.com"&gt;http://visualjquery.com&lt;/a&gt; . &lt;/p&gt;  &lt;p&gt;I've been using JQuery 8 months ago, but cleaning out code lately made me realize again&amp;#160; how much powerful this library is. take a look at this example for creating HTML nodes for a menu dynamically:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table cellspacing="0" cellpadding="4" width="100%" border="0"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td style="background-color: silver" width="464"&gt;&lt;strong&gt;before JQuery&lt;/strong&gt;&lt;/td&gt;        &lt;td width="30"&gt;&amp;#160;&lt;/td&gt;        &lt;td style="background-color: silver" width="527"&gt;&lt;strong&gt;after JQuery&lt;/strong&gt;&lt;/td&gt;     &lt;/tr&gt;      &lt;tr&gt;       &lt;td style="background-color: silver" width="463"&gt;         &lt;p&gt;var AutoDiv = document.getElementById('div'+ret[i].ID);&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;var tblContacts = AutoDiv.getElementsByTagName(&amp;quot;tbody&amp;quot;).item(0);             &lt;br /&gt;var tempRow = document.createElement('TR');             &lt;br /&gt;var tempTD = document.createElement('TD');             &lt;br /&gt;tempTD.TextToSet = escape(ret[i].Coordinates);             &lt;br /&gt;tempTD.AddressGroupTelephoneID = escape(ret[i].AddressGroupTelephoneID);             &lt;br /&gt;tempTD.onclick = SetText;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;tempTD.onmouseover = OnMouseOverForTempTD;             &lt;br /&gt;tempTD.onmouseout = OnMouseOutForTempTD;             &lt;br /&gt;tempRow.appendChild(tempTD);             &lt;br /&gt;tblContacts.appendChild(tempRow);&lt;/p&gt;       &lt;/td&gt;        &lt;td width="30"&gt;&amp;#160;&lt;/td&gt;        &lt;td style="background-color: silver" width="527"&gt;         &lt;p&gt;$('#div'+ret[i].ID).append($(&amp;quot;&amp;lt;tr&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;).append(            &lt;br /&gt;$(&amp;quot;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;quot;).attr(&amp;quot;TextToSet&amp;quot;,escape(ret[i].Coordinates))             &lt;br /&gt;.attr(&amp;quot;AddressGroupTelephoneID&amp;quot;,escape(ret[i].AddressGroupTelephoneID))             &lt;br /&gt;.mouseover(OnMouseOverForTempTD).mouseout(OnMouseOutForTempTD).click(setText));&lt;/p&gt;       &lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is just an example, JQuery has much more capabilities, and the best thing is that you don't have to worry about browser compatibility.&lt;/p&gt;  &lt;p&gt;make your life easier..&lt;/p&gt;</description><pubDate>Sun, 24 Aug 2008 22:27:45 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/jquery-makemylifeeasier</guid><category>General Software Development</category></item><item><title>Chaining methods used in JAVASCRIPT animations</title><link>http://weblogs.asp.net:80/diaaarfan/chaining-methods-used-in-javascript-animations</link><description>&lt;p&gt;Chaining is a syntax hack. It allows expressing multiple operations in small amount of code. All who are already familiar with JQUERY, they would be definitely familiar with Chaining methods.&lt;/p&gt;  &lt;p&gt;example : &lt;em&gt;$(&amp;quot;divSquare&amp;quot;).width(20).hide(); &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;This is done by returning the object at the end of each function. This can be thought of as selecting an HTML element and performing multiple operations on it. &lt;strong&gt;From another perspective we can think of these operations applied in an order, therefore we will be able to implement this technique in animations&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;example : &lt;/p&gt;  &lt;p&gt;&lt;em&gt;var myElement = {&lt;/em&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;_Element : &amp;quot;&amp;quot;,&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;init : function(id){ _Element = id; }, &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;moveToPosition : function(){&amp;#160; $(&amp;quot;#&amp;quot; + _Element).animate({top:250,left:250},2000); return this; }, &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;shake : function(){ var i = 0; for(i=1;i&amp;lt;10;i++){var r = 5; if(i%2 == 0) r = r * (-1); r = 250 + r; $(&amp;quot;#&amp;quot; + _Element).animate({top:250,left:r},100);} return this;}, &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;disappear : function(){ $(&amp;quot;#&amp;quot; + _Element).hide(200); return this; }&amp;#160; &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;}; &lt;/em&gt;&lt;/p&gt;    &lt;p&gt;Considering we have the &amp;quot;myElement&amp;quot; object with its action functions always returning the same object,&amp;#160; we will be able through methods chaining to create a &amp;quot;magical disappearing&amp;quot;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;function magicalDisappear()&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;{&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160; myElement.init(&amp;quot;TeztID&amp;quot;);&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&amp;#160;&amp;#160;&amp;#160; &lt;strong&gt;myElement.moveToPosition().shake().disappear();&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;}&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;blockquote&gt;&lt;/blockquote&gt;  &lt;p&gt;the magicalDisappear function is chaining multiple operations. These operations will be executed simultaneously, allowing us to easily define and execute animations.&amp;#160; Try it...&lt;/p&gt;</description><pubDate>Thu, 14 Aug 2008 23:29:02 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/chaining-methods-used-in-javascript-animations</guid><category>General Software Development</category><category>Javascript OOP</category></item><item><title>Private properties in JAVASCRIPT classes</title><link>http://weblogs.asp.net:80/diaaarfan/private-properties-in-javascript-classes</link><description>&lt;p&gt;Usually to define the scope of variables in languages like C#, you just use the member access modifiers: private, public, etc. But in case you're using JAVASCRIPT you will have to return another object within the object your initially declaring. The return object will include public members, like getter and setter members, while the initially declared object will contain the private members.&lt;/p&gt;  &lt;p&gt;example:    &lt;br&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;var Person = function(){&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;//_age will be used as a private property&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;var _age = 0;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;//this will return another object that will hold public members&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;return {&lt;/i&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;i&gt;//defining public getter and setter&lt;/i&gt;&lt;/p&gt;    &lt;p&gt;&lt;i&gt;GetAge : function() { return _age; },&lt;/i&gt;&lt;/p&gt;    &lt;p&gt;&lt;i&gt;SetAge : function(tempAge) { _age = tempAge; }&lt;/i&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;i&gt;};&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;};&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;&amp;nbsp;&lt;/p&gt;  &lt;p&gt;This way _age won't be accessible. It will be only accessed through public GetAge and SetAge in the return object.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;var a = new Person();      &lt;br&gt;alert(a._age);&amp;nbsp; // will alert undefined       &lt;br&gt;alert(a.GetAge()); // will&amp;nbsp; alert 0       &lt;br&gt;a.SetAge(5)       &lt;br&gt;alert(a.GetAge()); // will alert 5&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Hope this will be useful for you.&lt;/p&gt;</description><pubDate>Thu, 07 Aug 2008 14:59:00 GMT</pubDate><guid isPermaLink="true">http://weblogs.asp.net:80/diaaarfan/private-properties-in-javascript-classes</guid><category>General Software Development</category></item></channel></rss>