<?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>OmanDev &#187; NET</title>
	<atom:link href="http://www.omandev.net/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.omandev.net</link>
	<description>Technical, computer related articles and projects.</description>
	<lastBuildDate>Sat, 17 Jul 2010 18:54:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaScript, the language for them all!! (Jquery with gridview in asp.net 2.0)</title>
		<link>http://www.omandev.net/2008/09/javascript-the-language-for-them-all-jquery-with-gridview-in-asp-net-2-0/</link>
		<comments>http://www.omandev.net/2008/09/javascript-the-language-for-them-all-jquery-with-gridview-in-asp-net-2-0/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 07:13:00 +0000</pubDate>
		<dc:creator>Ali AL Lawati</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[2005]]></category>
		<category><![CDATA[datepicker]]></category>
		<category><![CDATA[gridview]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[NET]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=38</guid>
		<description><![CDATA[
Once a long time ago (in 80s) I think Assembly was considered the savior for when ever some one need to do some dirty work with their C or whatever language code and its not clear for him how to do it there or few things are not supported assembly comes to give you control [...]


Related posts:<ol><li><a href='http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/' rel='bookmark' title='Permanent Link: Calling ASP Functions from java script'>Calling ASP Functions from java script</a></li>
<li><a href='http://www.omandev.net/2007/05/search_resutls/' rel='bookmark' title='Permanent Link: search_Resutls'>search_Resutls</a></li>
<li><a href='http://www.omandev.net/2007/08/assembly-language-shift-instructions/' rel='bookmark' title='Permanent Link: Assembly Language &#8211; Shift Instructions'>Assembly Language &#8211; Shift Instructions</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p class="western" style="margin-bottom: 0.14in" id="m99k"><span class="Apple-style-span" style="font-weight: bold;"><br /></span></p>
<p class="western" style="margin-bottom: 0.14in" id="m99k0">Once a long time ago (in 80s) I think Assembly was considered the savior for when ever some one need to do some dirty work with their C or whatever language code and its not clear for him how to do it there or few things are not supported assembly comes to give you control on the tiniest transistor on the PC so you can do what ever in your mind (this is not just 80s it is applicable for all times <span  id="m99k1" style="font-family:Wingdings;"></span> )</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k2">In 90s the days of C++, Visual Basic 6.0, JAVA, PHP,… etc I think the savior was the C language, really when ever there was something you cannot do in any of these languages that you are working on, you would just connect it to a c DLL   or any c library file!!, using JNI for Java or active or DLL library for visual basic and similarly for others.</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k3">These days (WEB 2.0 days) all of the applications are moving to web using PHP J2EE, .NET 2005/2008, R on R and others. The common factor between them is they all need JavaScript to do the dirty work for them (working on client machines) so as in old days when all programmers needed to know assembly or as in 90s when all programmers needed to know C to do wonders with their softwares, these days developers must know JavaScript; cause it is the language for them all (applicable to any JavaScript framework (jquery, mootool, prototype))!!!</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k4">Ok that’s enough chit chat, now why I am talking all about this?? Because jquery enabled me to do something fun with asp.net 2.0’s gridview  </p>
<p class="western" style="margin-bottom: 0.14in" id="m99k5">
<p class="western" style="margin-bottom: 0.14in" id="m99k8">I will show you</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k9">I have added a jscript folder to my project and in it I have added the jquery and one of its plug-in: datepicker which will show a date picker calendar</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k10"><img src="http://docs.google.com/File?id=dhxndmq_1065drm38jqs_b" name="Object1" align="BOTTOM" width="194" height="97" id="m99k11" /></p>
<p class="western" style="margin-bottom: 0.14in" id="m99k12">Added jquery to my master page code so it will be available to all of my pages in the application that uses this master page</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k13"><span  id="m99k14" style="font-size:85%;"><span  id="m99k15" style="font-family:Courier New, monospace;"><span  id="m99k16" style="color:#0000ff;">&lt;</span><span  id="m99k17" style="color:#800000;">script</span> <span  id="m99k18" style="color:#ff0000;">type</span><span  id="m99k19" style="color:#0000ff;">=&#8221;text/javascript&#8221;</span> <span  id="m99k20" style="color:#ff0000;">src</span><span  id="m99k21" style="color:#0000ff;">=&#8221;Jscript/jquery-1.2.1.min.js&#8221;>&lt;/</span><span  id="m99k22" style="color:#800000;">script</span><span  id="m99k23" style="color:#0000ff;">></span></span></span></p>
<p class="western" style="margin-bottom: 0.14in; page-break-before: always" id="m99k24">
<p class="western" style="margin-bottom: 0.14in" id="m99k27">Now I have a gridview (well for my application need I have a very complex 3 level nested gridview)</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k28"><img src="http://docs.google.com/File?id=dhxndmq_1066hcmg4qqq_b" name="Object2" align="BOTTOM" width="387" height="290" id="m99k29" /></p>
<p class="western" style="margin-bottom: 0.14in" id="m99k30">Now close date is a template column where I have a textbox  <img src="http://docs.google.com/File?id=dhxndmq_1067f3jbsfgz_b" name="Object3" align="BOTTOM" width="194" height="194" id="m99k32" />  I made the cssclass of the text box equals to “datepickerz” <span  id="m99k35" style="font-size:85%;"><span  id="m99k36" style="font-family:Courier New, monospace;"><span  id="m99k37" style="color:#0000ff;">&lt;</span><span  id="m99k38" style="color:#800000;">asp</span><span  id="m99k39" style="color:#0000ff;">:</span><span  id="m99k40" style="color:#800000;">TextBox</span> <span  id="m99k41" style="color:#ff0000;">ID</span><span  id="m99k42" style="color:#0000ff;">=&#8221;TextBox1&#8243;</span> <span  id="m99k43" style="color:#ff0000;">runat</span><span  id="m99k44" style="color:#0000ff;">=&#8221;server&#8221;</span> <span  id="m99k45" style="color:#ff0000;">Text</span><span  id="m99k46" style="color:#0000ff;">=&#8217;</span><span style="background: #ffff00" id="m99k47">&lt;%</span># Bind(&#8220;close_date&#8221;) <span style="background: #ffff00" id="m99k48">%></span><span  id="m99k49" style="color:#0000ff;">&#8216;</span> <span  id="m99k50" style="color:#ff0000;">CssClass</span><span  id="m99k51" style="color:#0000ff;">=&#8221;datepickerz&#8221;</span> <span  id="m99k52" style="color:#ff0000;">Width</span><span  id="m99k53" style="color:#0000ff;">=&#8221;89px&#8221;>&lt;/</span><span  id="m99k54" style="color:#800000;">asp</span><span  id="m99k55" style="color:#0000ff;">:</span><span  id="m99k56" style="color:#800000;">TextBox</span><span  id="m99k57" style="color:#0000ff;">></span></span></span></p>
<p class="western" style="margin-bottom: 0.14in" id="m99k58">Now I need for each row in this complex gridview the textbox to be a datepicker so simply I wrote the following jquery script</p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k59">     <span  id="m99k60" style="font-size:85%;"><span  id="m99k61" style="font-family:Courier New, monospace;"><span  id="m99k62" style="color:#0000ff;">&lt;</span><span  id="m99k63" style="color:#800000;">script</span> <span  id="m99k64" style="color:#ff0000;">type</span><span  id="m99k65" style="color:#0000ff;">=&#8221;text/javascript&#8221;</span> <span  id="m99k66" style="color:#ff0000;">src</span><span  id="m99k67" style="color:#0000ff;">=&#8221;Jscript/ui.datepicker.js&#8221;>&lt;/</span><span  id="m99k68" style="color:#800000;">script</span><span  id="m99k69" style="color:#0000ff;">></span></span></span></p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k70">     <span  id="m99k71" style="font-size:85%;"><span  id="m99k72" style="font-family:Courier New, monospace;"><span  id="m99k73" style="color:#0000ff;">&lt;</span><span  id="m99k74" style="color:#800000;">script</span> <span  id="m99k75" style="color:#ff0000;">type</span><span  id="m99k76" style="color:#0000ff;">=&#8221;text/javascript&#8221;</span> <span  id="m99k77" style="color:#0000ff;">></span> </span></span> </p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k78">
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k79">
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k80">             <span  id="m99k81" style="font-size:85%;"><span  id="m99k82" style="font-family:Courier New, monospace;">$(document).ready(<span  id="m99k83" style="color:#0000ff;">function</span>() {</span></span></p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k84">                  <span  id="m99k85" style="font-size:85%;"><span  id="m99k86" style="font-family:Courier New, monospace;">$(<span  id="m99k87" style="color:#800000;">&#8216;.datepickerz&#8217;</span>).each( <span  id="m99k88" style="color:#0000ff;">function</span> () {</span></span></p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k89">                         <span  id="m99k90" style="font-size:85%;"><span  id="m99k91" style="font-family:Courier New, monospace;">$(<span  id="m99k92" style="color:#0000ff;">this</span>).attachDatepicker();</span></span></p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k93">                 <span  id="m99k94" style="font-family:Courier New, monospace;"><span  id="m99k95" style="font-size:85%;">});</span></span></p>
<p class="western" style="margin-bottom: 0in; line-height: 100%" id="m99k96">          <span  id="m99k97" style="font-family:Courier New, monospace;"><span  id="m99k98" style="font-size:85%;">});    </span></span> </p>
<p class="western" style="margin-bottom: 0.14in" id="m99k99">    <span  id="m99k100" style="font-size:85%;"><span  id="m99k101" style="font-family:Courier New, monospace;"><span  id="m99k102" style="color:#0000ff;">&lt;/</span><span  id="m99k103" style="color:#800000;">script</span><span  id="m99k104" style="color:#0000ff;">></span></span></span></p>
<p class="western" style="margin-bottom: 0.14in" id="m99k105">Which is one of the beautiful magic of jquery it allows to pick all controls that have been assigned the class <span  id="m99k106" style="font-size:85%;"><span  id="m99k107" style="font-family:Courier New, monospace;"><span  id="m99k108" style="color:#800000;">datepickerz </span></span></span>and then for each control I just attach it with the datepicker.</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k109">The result whenever I click on the textbox in any editable row in the complex gridview I will get a floating calendar to select a date that will be stored in the textbox.</p>
<p class="western" style="margin-bottom: 0.14in" id="m99k110">I know I have not discovered the atoms by doing this simple activity, but I wanted to mention it because as I see around me (in Oman) most of .NET developers are not aware of Jquery and other JavaScript frameworks and their features.</p>
<div class="blogger-post-footer">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
omandev.net English feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/' rel='bookmark' title='Permanent Link: Calling ASP Functions from java script'>Calling ASP Functions from java script</a></li>
<li><a href='http://www.omandev.net/2007/05/search_resutls/' rel='bookmark' title='Permanent Link: search_Resutls'>search_Resutls</a></li>
<li><a href='http://www.omandev.net/2007/08/assembly-language-shift-instructions/' rel='bookmark' title='Permanent Link: Assembly Language &#8211; Shift Instructions'>Assembly Language &#8211; Shift Instructions</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2008/09/javascript-the-language-for-them-all-jquery-with-gridview-in-asp-net-2-0/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Calling ASP Functions from java script</title>
		<link>http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/</link>
		<comments>http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 20:49:00 +0000</pubDate>
		<dc:creator>Ali AL Lawati</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://66.147.242.194/~omandevn/wrd1/wordpress/?p=35</guid>
		<description><![CDATA[Umm i think some may get confused that isn&#8217;t it that Ajax can call server side functions from JavaScript ?? ! well thats write but i want to talk about those people who are still using Microsoft .NET 2005 and not lucky enough to get gaya or other ajax plug-in from Microsoft, or those who [...]


Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/10/jcodebase-1-1-beta/' rel='bookmark' title='Permanent Link: JCodeBase 1.1 Beta'>JCodeBase 1.1 Beta</a></li>
<li><a href='http://www.omandev.net/2008/09/javascript-the-language-for-them-all-jquery-with-gridview-in-asp-net-2-0/' rel='bookmark' title='Permanent Link: JavaScript, the language for them all!! (Jquery with gridview in asp.net 2.0)'>JavaScript, the language for them all!! (Jquery with gridview in asp.net 2.0)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Umm i think some may get confused that isn&#8217;t it that <a href="http://en.wikipedia.org/wiki/Ajax_%28programming%29" title="Ajax (programming)" rel="wikipedia" target="_blank" class="zem_slink">Ajax</a> can call server side functions from JavaScript ?? ! well thats write but i want to talk about those people who are still using <a href="http://www.microsoft.com/" title="Microsoft" rel="homepage" target="_blank" class="zem_slink">Microsoft</a> .NET 2005 and not lucky enough to get gaya or other ajax plug-in from Microsoft, or those who are still not ready to deal with Ajax and other Ajax/<a href="http://en.wikipedia.org/wiki/JavaScript" title="JavaScript" rel="wikipedia" target="_blank" class="zem_slink">JavaScript</a> plug ins such as jquery .</p>
<p>Most of the old .NET developer are used to have their <a href="http://en.wikipedia.org/wiki/Web_application" title="Web application" rel="wikipedia" target="_blank" class="zem_slink">web applications</a> deal with post-backs but very few of them really knows how these post-backs do work. well most of the things in .NET application are done depending on  client side script (JavaScript).</p>
<p>For that when you have a good amount of JavaScript controlling your application you need to know how to make that JavaScript call an asp function.</p>
<p>Before explaining how to do this first lets see why do we need it ? Well may be you will need to do something with JavaScript before calling server side codes, like validating entered data ( well i know that is a very bad example since in .NET there is a ready validating controles) a better example lets say you have created a web page that allow users to draw for example mind maps, or charts, or mouse gestures so that when user drag his mouse in a specific way there will be a specific response from your web application.</p>
<p>well in all of these examples JavaScript or JavaScript frameworks like jquery  will be doing most of the things in the application here the decision to make a server side function call should be given to java script code.</p>
<p>Calling asp.NET function by JavaScript you need to do a simple trick,</p>
<p>Well as i found from some of my tries to  get there, that you can not do it having normal form buttons you will need at least one &#8220;link button&#8221; (sure you can hide it, but NEVER make visible = false because it will be removed from the HTML code; instead apply <a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets" title="Cascading Style Sheets" rel="wikipedia" target="_blank" class="zem_slink">CSS</a> style on it that make it hidden)</p>
<p><span style="color: rgb(255, 0, 0);">visibility</span>:<span style="color: rgb(51, 102, 255);">hidden</span>;</p>
<p>then you need to call the post back function that usually is called if you really do click that link_button and in the asp.NET code do call your asp function in the link_button event handler function.</p>
<p>well thats a lot of blah blah, theoretical talks, well then lets get into action then.</p>
<p>here i will show a very simple example (sorry i am out of creativity by now so the example will be very simple) i created a very simple page with a text box an a link button</p>
<p><textarea rows="10" cols="40"><br />
<form id="form1" runat="server">>
<div>      <asp:textbox id="TextBox1" runat="server"></asp:textbox>  </div>
<p>     <asp:linkbutton style="font-weight: bold;">CssClass=&#8221;hdn&#8221; ID=&#8221;LinkButton1&#8243; runat=&#8221;server&#8221;         onclick=&#8221;LinkButton1_Click&#8221;>LinkButton</asp:linkbutton> </p>
</p></form>
<p></textarea></p>
<p>i added a very simple response code to the link button click event in C#<br /><textarea rows="5" cols="40">  protected void LinkButton1_Click(object sender, EventArgs e)  {  Response.Write(&#8220;yooohooo&#8221;);  }</textarea><br />well yeah this is our server side function (i told you this week i am out of creativity).</p>
<p>and then i added they style to hide the link button<br /><textarea rows="4" cols="40"><br />
<style>    .hdn{ visibility:hidden;    }    </style>
<p></textarea><br />now even in the IDE you just cannot see the link button</p>
<p>now the real thing is in the java script i have done a very simple and a very boring thing witch is on each button press it makes the text in the text box uppercase and if the length of text reaches to 6 it will call the server side function</p>
<p>i have added it just before the end of form tag</p>
<p><textarea rows="20" cols="40">     <script type="text/javascript">    var t =document.getElementById("TextBox1");          // well you can imagen this function is any thing else may be figuring out how did you made your mouse gesture     document.getElementById("TextBox1").onkeydown = function ss(){        t.value= t.value.toUpperCase();            // may be here there is a condition to know if it should call the server side function       if(t.value.length >5)      {   __doPostBack('LinkButton1','');        }        }    </script></textarea><br />well you can see the real point is in the function  __doPostBack(&#8221;,&#8221;)<br />which is created by Visual Studio it self you do not have to program it and it can call server side functions by its own way (well what you do not know that there are a lot of hidden fields in your page that are getting created by visual studio and are used for these kind of stuff)</p>
<p>and the reason i say that we must have a link button is that i found Visual studio do not create this JavaScript function __doPostBack(&#8221;,&#8221;)  if we dont have link button</p>
<p>well thats all for today i think hope this thing (which i had to search and try a lot of things to be able to do) will help you in your projects
<div class="blogger-post-footer">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
omandev.net English feed</div>


<p>Related posts:<ol><li><a href='http://www.omandev.net/2008/08/adding-a-friendly-splash-waiting-screen-while-the-code-is-being-executed-in-asp/' rel='bookmark' title='Permanent Link: Adding a friendly splash (waiting screen) while the code is being executed in ASP'>Adding a friendly splash (waiting screen) while the code is being executed in ASP</a></li>
<li><a href='http://www.omandev.net/2007/10/jcodebase-1-1-beta/' rel='bookmark' title='Permanent Link: JCodeBase 1.1 Beta'>JCodeBase 1.1 Beta</a></li>
<li><a href='http://www.omandev.net/2008/09/javascript-the-language-for-them-all-jquery-with-gridview-in-asp-net-2-0/' rel='bookmark' title='Permanent Link: JavaScript, the language for them all!! (Jquery with gridview in asp.net 2.0)'>JavaScript, the language for them all!! (Jquery with gridview in asp.net 2.0)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.omandev.net/2008/08/calling-asp-functions-from-java-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
