<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>ASP.Net @ timstall.dotnetdevelopersjournal.com</title><link>http://timstall.dotnetdevelopersjournal.com/</link><description>(ASP.Net) </description><copyright>Copyright 2008 timstall.dotnetdevelopersjournal.com</copyright><generator></generator><lastBuildDate>Sat, 06 Sep 2008 21:21:00 GMT</lastBuildDate><image><title>ASP.Net @ timstall.dotnetdevelopersjournal.com</title><url>http://res.sys-con.com/portlet/163/featured-blog-graphic-145.gif</url><link>http://timstall.dotnetdevelopersjournal.com/</link></image><ttl>360</ttl><docs>http://backend.userland.com/rss</docs><item><title>Hashtables in JavaScript</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/hashtables_in_javascript.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/hashtables_in_javascript.htm</link><pubDate>Wed, 22 Feb 2006 03:41:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=hashtables%5Fin%5Fjavascript</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>As a bit of trivia for the day, JavaScript can handle pseudo-hashtables, via the Array object. You can reference the item with its key, and enumerate through all the objects.</p>
<blockquote>
<p><span id="ctl00_ContentPlaceHolder1_output">function DoHashTest()<br />{<br />&nbsp; var h = <span class="kwrd">new</span> Array();<br />&nbsp; <strong>h[<span class="str">&quot;aaa&quot;</span>] = <span class="str">&quot;Aardvark&quot;</span>;</strong><br />&nbsp; h[<span class="str">&quot;bbb&quot;</span>] = <span class="str">&quot;Babboon&quot;</span>;<br />&nbsp; <br />&nbsp; var s = <span class="str">&quot;&quot;</span>;<br />&nbsp; <span class="rem">//This won't work, length will be 0.</span><br />&nbsp; <span class="kwrd">for</span> (var i = 0; i &lt; h.length; i++)<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp; s += h[i]; <br />&nbsp; }<br /><br />&nbsp; <span class="rem">//Cycle through like a hash:</span><br />&nbsp; <span class="kwrd">for</span> (var i <span class="kwrd">in</span> h)<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; s += i;<br />&nbsp; }<br />}</span></p>
</blockquote>]]></description></item><item><title>JavaScript Debugging in 2005</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/javascript_debugging_in_2005.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/javascript_debugging_in_2005.htm</link><pubDate>Tue, 31 Jan 2006 03:12:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=javascript%5Fdebugging%5Fin%5F2005</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[I had written about <a href="http://timstall.dotnetdevelopersjournal.com/debugging_javascript_in_visual_studio.htm">JavaScript debugging in 2003</a> with the Running Documents Window. In 2005 they do things a little differently. Instead of the running documents window, there is the script explorer.
<p>One immediate perk is that the script explorer has source code color-coded, whereas the running document window did not.</p>
<p>Check out <a href="http://blogs.msdn.com/jorman/archive/2006/01/23/516632.aspx">Microsoft's Jerry Orman's blog to see how to debug in VS2005</a>.</p>]]></description></item><item><title>Pair and Triplet classes</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/pair_and_triplet_classes.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/pair_and_triplet_classes.htm</link><pubDate>Thu, 26 Jan 2006 14:32:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=pair%5Fand%5Ftriplet%5Fclasses</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>There are some Framework classes out there that are useful, but infrequently used. In my experience, <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.pair.aspx">System.Web.UI.Pair</a> and <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.triplet.aspx">System.Web.UI.Triplet</a> are two such examples. These provide basic utilities (like serialization) to store two or three related objects into single object. They have predictable members, for example Pair has a &quot;First&quot; and &quot;Second&quot; property that can be set either in the constructor or once instantiated.</p>
<p>They're simple classes, but are easy and helpful to use in web applications. Of course you could write your own container, but this saves you the step.</p>]]></description></item><item><title>Sudoku board enhanced with DHTML</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/sudoku_board_enhanced_with_dhtml.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/sudoku_board_enhanced_with_dhtml.htm</link><pubDate>Fri, 06 Jan 2006 15:15:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=sudoku%5Fboard%5Fenhanced%5Fwith%5Fdhtml</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>I've blogged about Html, JavaScript, CSS, and combining them into DHTML. Normally I apply this to enterprise architecture, but you can apply this to online games too. One fun application of this is the Sudoku solver, editor, and generator at <a href="http://www.thetoolboxsite.com/Sudoku.aspx">http://www.thetoolboxsite.com/Sudoku.aspx</a>. Sudoku is a logic game of 9x9 cells, where each cell contains a single digit 1-9, and no row, column, or 3x3 square can have the same digit twice. Apparently it's becoming pretty popular, and hence people are making web versions of it. Here's a screen shot of a board in progress:</p>
<p><a href="http://www.thetoolboxsite.com/Sudoku.aspx" target="_blank"><img height="429" alt="Sudoku Board" src="http://files.blog-city.com/files/J05/88352/p/f/sudoku.jpg" width="412" border="0" /></a></p>
<p>&nbsp;The Sudoku mentioned above has a lot of JavaScript on it. Some initial interesting JavaScript features are:</p>
<ul>
    <li>You can navigate the cells with the arrow keys, and it highlights the current cell. This kind of functionality can be implemented by using the onkeydown, onkeyup, and onfocus events to first select another cell (using .select() ), and then change the style (using .style=).</li>
    <li>If you type multiple values into a cell - something that's useful to record your notes - then the text shrinks accordingly to make room. This can also be done by the onkeyup event setting the styles.</li>
    <li>If you type an invalid value into a cell, like the letter &quot;a&quot; (only digits are allowed), it won't let you - there is JavaScript to block invalid user input. This can be done by returning false on the onkeydown event (i.e.: onkeydown=&quot;return IsValid()&quot; ).</li>
    <li>If you click the &quot;paste&quot; button, it gets the text from the JavaScript clipboard, serializes it into a board object, and then updates the UI. Vice versa with the paste.</li>
</ul>
<p>There's a lot more stuff going on there, but even with these there is a classic principle of programming: <em>Making computer games teaches you things to make better enterprise applications!</em> All of those input features could be useful to an enterprise app: using JavaScript validation to not even let you type invalid input, navigating and highlighting cells in a grid with the arrows (like in Excel), or juggling data to and from the clipboard. These are all good examples of using JavaScript to enhance your web UI.</p>]]></description></item><item><title>Adding and Removing items from an Html ListBox</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/adding_and_removing_items_from_an_html_listbox.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/adding_and_removing_items_from_an_html_listbox.htm</link><pubDate>Wed, 28 Dec 2005 14:10:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=adding%5Fand%5Fremoving%5Fitems%5Ffrom%5Fan%5Fhtml%5Flistbox</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>ASP.Net makes things easy, like adding and removing items from an HTML listbox. The problem is that these items are stored as inner nodes... it's not just as simple as setting a value property. Therefore you modify items by modifying the DOM itself. Here's an Html page to do that. It gives each item a description and id (for lookup purposes). The methods that really matter (i.e. reuse them into your own code) are AddItem and RemoveItem. Both take a listBox object, and id, and AddItem also takes the text to display.</p>
<p>Note that in pure html, both the ListBox and Dropdown are created from the &lt;select&gt; tag. However a ListBox has a size attribute &gt; 1.</p>
<blockquote>
<p><font face="Courier New"><span id="ctl00_ContentPlaceHolder1_output"><span class="kwrd"><font color="#0000ff" size="2">&lt;!</font></span><font size="2"><span class="html"><font color="#800000">DOCTYPE</font></span> <span class="attr"><font color="#ff0000">HTML</font></span> <span class="attr"><font color="#ff0000">PUBLIC</font></span> <font color="#0000ff"><span class="kwrd">&quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">html</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">title</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;/</font></span><span class="html"><font color="#800000">title</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;GENERATOR&quot;</font></span> <span class="attr"><font color="#ff0000">content</font></span><font color="#0000ff"><span class="kwrd">=&quot;Microsoft Visual Studio .NET 7.1&quot;&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span>=<span class="attr"><font color="#ff0000">ProgId</font></span> <span class="attr"><font color="#ff0000">content</font></span>=<span class="attr"><font color="#ff0000">VisualStudio</font></span>.<span class="attr"><font color="#ff0000">HTML</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span>=<span class="attr"><font color="#ff0000">Originator</font></span> <span class="attr"><font color="#ff0000">content</font></span><font color="#0000ff"><span class="kwrd">=&quot;Microsoft Visual Studio .NET 7.1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">script</font></span> <span class="attr"><font color="#ff0000">language</font></span><font color="#0000ff"><span class="kwrd">=&quot;javascript&quot;&gt;</span><br /></font>&lt;!--<br /><span class="kwrd"><font color="#0000ff">function</font></span> DoAdd()<br />{<br />&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> strText = document.getElementById(<span class="str"><font color="#006080">&quot;TxtContent&quot;</font></span>).value;<br />&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> strId = document.getElementById(<span class="str"><font color="#006080">&quot;TxtId&quot;</font></span>).value;<br />&nbsp; AddItem(document.getElementById(<span class="str"><font color="#006080">&quot;Select1&quot;</font></span>), strText, strId);<br />}<br /><br /><span class="kwrd"><font color="#0000ff">function</font></span> DoRemove()<br />{<br />&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> strId = document.getElementById(<span class="str"><font color="#006080">&quot;TxtId&quot;</font></span>).value;<br />&nbsp; RemoveItem(document.getElementById(<span class="str"><font color="#006080">&quot;Select1&quot;</font></span>), strId);<br />}<br /><br /><br /><span class="kwrd"><font color="#0000ff">function</font></span> <strong>AddItem</strong>(objListBox, strText, strId)<br />{<br />&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> newOpt;<br />&nbsp; newOpt = document.createElement(<span class="str"><font color="#006080">&quot;OPTION&quot;</font></span>);<br />&nbsp; newOpt = <span class="kwrd"><font color="#0000ff">new</font></span> Option(strText,strText);<br />&nbsp; newOpt.id = strId;<br />&nbsp; objListBox.add(newOpt);<br />}<br /><br /><span class="kwrd"><font color="#0000ff">function</font></span> <strong>RemoveItem</strong>(objListBox, strId)<br />{<br />&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> intIndex = GetItemIndex(objListBox, strId);<br />&nbsp; <span class="kwrd"><font color="#0000ff">if</font></span> (intIndex != -1)<br />&nbsp;&nbsp;&nbsp; objListBox.remove(intIndex);<br />}<br /><br /><span class="kwrd"><font color="#0000ff">function</font></span> GetItemIndex(objListBox, strId)<br />{<br />&nbsp; <span class="kwrd"><font color="#0000ff">for</font></span> (<span class="kwrd"><font color="#0000ff">var</font></span> i = 0; i &lt; objListBox.children.length; i++)<br />&nbsp; {<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> strCurrentValueId = objListBox.children[i].id;<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">if</font></span> (strId == strCurrentValueId)<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">return</font></span> i;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp; }<br />&nbsp; <span class="kwrd"><font color="#0000ff">return</font></span> -1;<br />}<br /><br /><font color="#008000"><span class="rem">//--&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">script</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>ID: <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">INPUT</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;TxtId&quot;</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;text&quot;</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;Text1&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><span class="kwrd"><font color="#0000ff">=&quot;server&quot;</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;1234&quot;&gt;</font></span>&nbsp; Text: <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">INPUT</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;TxtContent&quot;</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;text&quot;</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;Text1&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><span class="kwrd"><font color="#0000ff">=&quot;server&quot;</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;ddddd&quot;&gt;&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;</font></span><span class="html"><font color="#800000">INPUT</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;button&quot;</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;Add&quot;</font></span> <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;DoAdd()&quot;</font></span> <span class="attr"><font color="#ff0000">ID</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button1&quot;</font></span> <span class="attr"><font color="#ff0000">NAME</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button1&quot;&gt;</font></span> <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">INPUT</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;button&quot;</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;Remove&quot;</font></span> <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;DoRemove()&quot;</font></span> <span class="attr"><font color="#ff0000">ID</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button2&quot;</font></span> <span class="attr"><font color="#ff0000">NAME</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button2&quot;&gt;</font></span> <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;</font></span><span class="html"><font color="#800000">SELECT</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Select1&quot;</font></span> <strong><span class="attr"><font color="#ff0000">size</font></span><span class="kwrd"><font color="#0000ff">=&quot;8&quot;</font></span></strong> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;Select1&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><span class="kwrd"><font color="#0000ff">=&quot;server&quot;</font></span> <span class="attr"><font color="#ff0000">style</font></span><font color="#0000ff"><span class="kwrd">=&quot;WIDTH: 176px; HEIGHT: 128px&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">OPTION</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;a1&quot;&gt;</font></span>aaa<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">OPTION</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">OPTION</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;b1&quot;&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">OPTION</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">OPTION</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;c1&quot;&gt;</font></span>ccc<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">OPTION</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">SELECT</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">html</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
</blockquote>]]></description></item><item><title>DHTML IV: Highlighting a table row or column</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/dhtml_iv_highlighting_a_table_row_or_column.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/dhtml_iv_highlighting_a_table_row_or_column.htm</link><pubDate>Mon, 12 Dec 2005 21:38:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=dhtml%5Fiv%5Fhighlighting%5Fa%5Ftable%5Frow%5For%5Fcolumn</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Every now and then it's nice to do some fun UI enhancements. We can use DHTML to select a row or column of a table. We can do this by:</p>
<ol>
    <li>Decide what event triggers the highlight (clicking or mouse hovering, any cell or just the header)</li>
    <li>Have a way to reference the row or column</li>
    <li>Attach the appropriate JavaScript event handler, and have it change the property of the target row or column.</li>
</ol>
<p>Highlighting rows is easy, just add the event handles to the &lt;tr&gt; tag and reference it with the &quot;this.&quot; keyword:</p>
<blockquote>
<p><font face="Courier New"><span id="ctl00_ContentPlaceHolder1_output"><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TABLE</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Table2&quot;</font></span> <span class="attr"><font color="#ff0000">cellSpacing</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">cellPadding</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">width</font></span><span class="kwrd"><font color="#0000ff">=&quot;300&quot;</font></span> <span class="attr"><font color="#ff0000">border</font></span><font color="#0000ff"><span class="kwrd">=&quot;1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Header 1<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Header 2<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Header 3<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span> <span class="attr"><font color="#ff0000">onmouseover</font></span><span class="kwrd"><font color="#0000ff">=&quot;this.className='SelectRow'&quot;</font></span> <span class="attr"><font color="#ff0000">onmouseout</font></span><font color="#0000ff"><span class="kwrd">=&quot;this.className=''&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>a<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>b<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>c<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span> <span class="attr"><font color="#ff0000">onmouseover</font></span><span class="kwrd"><font color="#0000ff">=&quot;this.className='SelectRow'&quot;</font></span> <span class="attr"><font color="#ff0000">onmouseout</font></span><font color="#0000ff"><span class="kwrd">=&quot;this.className=''&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>d<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>e<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>f<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TABLE</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
</blockquote>
<p>Highlight columns is a little more tricky. As there isn't a &quot;column&quot; object (at least not to my knowledge), you need to select each cell individually. Therefore we need to add an id to each cell, and then cycle through them. Note that this doesn't interfere if you wanted to make the columns be hyperlinks, perhaps to fire off some &quot;sort&quot; method. If we give each cell a structured id like so:</p>
<blockquote>
<p><font face="Courier New"><span id="ctl00_ContentPlaceHolder1_output"><font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TABLE</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Table1&quot;</font></span> <span class="attr"><font color="#ff0000">cellSpacing</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">cellPadding</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">width</font></span><span class="kwrd"><font color="#0000ff">=&quot;300&quot;</font></span> <span class="attr"><font color="#ff0000">border</font></span><font color="#0000ff"><span class="kwrd">=&quot;1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_0_a&quot;</font></span> <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;SelectColumn('a')&quot;&gt;</font></span>Header 1<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_0_b&quot;</font></span> <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;SelectColumn('b')&quot;&gt;</font></span>Header 2<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_0_c&quot;</font></span> <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;SelectColumn('c')&quot;&gt;</font></span>Header 3<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_1_a&quot;&gt;</font></span>a<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_1_b&quot;&gt;</font></span>b<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_1_c&quot;&gt;</font></span>c<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_2_a&quot;&gt;</font></span>d<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_2_b&quot;&gt;</font></span>e<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;td_2_c&quot;&gt;</font></span>f<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TABLE</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
</blockquote>
<p>... then we can use JavaScript to cycle through all the cells in a column:</p>
<blockquote>
<p><font face="Courier New"><span id="ctl00_ContentPlaceHolder1_output"><font size="2">&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">script</font></span> <span class="attr"><font color="#ff0000">language</font></span><font color="#0000ff"><span class="kwrd">=&quot;javascript&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> strCurrentColumn = 0;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">var</font></span> intRowCount = 3;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">function</font></span> SelectColumn(strIndex) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"><span class="rem">//clear previous column</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">if</font></span> ( strCurrentColumn != 0 )<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">for</font></span> (<span class="kwrd"><font color="#0000ff">var</font></span> i = 0; i &lt; intRowCount; i++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'td_'</font></span> + i + <span class="str"><font color="#006080">'_'</font></span> + strCurrentColumn).className = <span class="str"><font color="#006080">''</font></span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"><span class="rem">//set new column:</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strCurrentColumn = strIndex;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">for</font></span> (<span class="kwrd"><font color="#0000ff">var</font></span> i = 0; i &lt; intRowCount; i++) {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'td_'</font></span> + i + <span class="str"><font color="#006080">'_'</font></span> + strCurrentColumn).className = <span class="str"><font color="#006080">'SelectColumn'</font></span>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">script</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
</blockquote>
<p>Lastly, we could combine these two approaches such that you could select both the column and row - that might be helpful for a big table. Also, you could have some script to give alternating rows different colors too.</p>
<p>These are all straight-forward techniques, and they may be able to make your tables a little more flashy.</p>]]></description></item><item><title>DHTML III: Detecting the mouse click and coordinates</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/dhtml_iii_detecting_the_mouse_click_and_coordinates.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/dhtml_iii_detecting_the_mouse_click_and_coordinates.htm</link><pubDate>Thu, 08 Dec 2005 14:03:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=dhtml%5Fiii%5Fdetecting%5Fthe%5Fmouse%5Fclick%5Fand%5Fcoordinates</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Continuing my DHTML posts (<a title="read entry" href="http://timstall.dotnetdevelopersjournal.com/dhtml_i_intro_and_positioning_text.htm">DHTML I: Intro and Positioning Text</a>, and <a title="read entry" href="http://timstall.dotnetdevelopersjournal.com/dhtml_ii_using_hidden_divs_instead_of_popup_windows.htm">DHTML II: Using Hidden Divs instead of Popup windows</a>), there are more cool things you can do, such as detecting the mouse click and its coordinates. This is useful if you're trying to make a more complex UI or perhaps even a simple game. Perhaps the best way to flush this out is with an example. Say you want to be able to click a table cell, and have a yellow dot appear where ever you clicked. You could do this by first getting the mouse coordinates, and then positioning a div tag (which holds the image for the dot) to those coordinates.</p>
<p>Here's the code, then I'll explain it:</p>
<blockquote>
<p><font face="Courier New"><span id="ctl00_ContentPlaceHolder1_output"><span class="kwrd"><font color="#0000ff" size="2">&lt;</font></span><font size="2"><span class="html"><font color="#800000">HTML</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">HEAD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">title</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>DetectClick<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">title</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;GENERATOR&quot;</font></span> <span class="attr"><font color="#ff0000">Content</font></span><font color="#0000ff"><span class="kwrd">=&quot;Microsoft Visual Studio .NET 7.1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;CODE_LANGUAGE&quot;</font></span> <span class="attr"><font color="#ff0000">Content</font></span><font color="#0000ff"><span class="kwrd">=&quot;C#&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;vs_defaultClientScript&quot;</font></span> <span class="attr"><font color="#ff0000">content</font></span><font color="#0000ff"><span class="kwrd">=&quot;JavaScript&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">meta</font></span> <span class="attr"><font color="#ff0000">name</font></span><span class="kwrd"><font color="#0000ff">=&quot;vs_targetSchema&quot;</font></span> <span class="attr"><font color="#ff0000">content</font></span><font color="#0000ff"><span class="kwrd">=&quot;http://schemas.microsoft.com/intellisense/ie5&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .divAbsPosition1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z-index: 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left: 0px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; position: absolute;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; top: 0px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; visibility:hidden;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">script</font></span> <span class="attr"><font color="#ff0000">language</font></span>=<span class="attr"><font color="#ff0000">javascript</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!--<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">function</font></span> doSomething()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong><span class="kwrd"><font color="#0000ff">var</font></span> e = window.<span class="kwrd"><font color="#0000ff">event</font></span>;</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <strong><span class="kwrd"><font color="#0000ff">var</font></span> s = e.clientX + <span class="str"><font color="#006080">','</font></span> + e.clientY;</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'span1'</font></span>).innerText = s;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"><span class="rem">//set pic:</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'DivDot'</font></span>).style.visibility = <span class="str"><font color="#006080">'visible'</font></span>;<br /><strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'DivDot'</font></span>).style.left = e.clientX - 10;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; document.getElementById(<span class="str"><font color="#006080">'DivDot'</font></span>).style.top = e.clientY - 10;</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"><span class="rem">//--&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">script</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">HEAD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">div</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;DivDot&quot;</font></span> <span class="attr"><font color="#ff0000">class</font></span><font color="#0000ff"><span class="kwrd">=&quot;divAbsPosition1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">img</font></span> <span class="attr"><font color="#ff0000">src</font></span><font color="#0000ff"><span class="kwrd">=&quot;dot.gif&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">div</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">table</font></span> <span class="attr"><font color="#ff0000">border</font></span>=<span class="attr"><font color="#ff0000">1</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">td</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Click on next cell:<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">td</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">td</font></span> <span class="attr"><font color="#ff0000">width</font></span>=<span class="attr"><font color="#ff0000">300px</font></span> <span class="attr"><font color="#ff0000">height</font></span>=<span class="attr"><font color="#ff0000">100px</font></span> <span class="attr"><font color="#ff0000">onmousedown</font></span><font color="#0000ff"><span class="kwrd">=&quot;doSomething()&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Mouse coordinates: (<span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">span</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;span1&quot;&gt;&lt;/</font></span><span class="html"><font color="#800000">span</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>)<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">td</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">table</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">HTML</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
</blockquote>
<p>The cell has an onclick that triggers a JavaScript method. This method gets the window event, from which it can get the mouse click coordinates. We then simply set the div tag to that position. It's surprisingly simple. There's also a deeper <a href="http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html">discussion of this here</a>.</p>
<p>Of course, you could combine these three DHTML posts (positioning, visibility, and mouse clicks), and the <a href="http://timstall.dotnetdevelopersjournal.com/implementing_a_timer_in_javascript_with_settimeout.htm">JavaScript timer</a>, to create simple games. For example, you could have another dot move by getting its position set by the timer, and then detect if you clicked that moving dot by comparing the mouse coordinates. There's a lot of potential.</p>]]></description></item><item><title>Changing Custom Validator Messages</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/changing_custom_validator_messages.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/changing_custom_validator_messages.htm</link><pubDate>Wed, 07 Dec 2005 15:43:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=changing%5Fcustom%5Fvalidator%5Fmessages</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Sometimes you may want to have one custom validator potentially display two different error messages depending on context. For example you may make your own date validator (perhaps to work with your own custom calendar control), and this control may first validate format (&quot;xyz&quot; is not a date, &quot;12/3/2005&quot; is), and then validate integration with the rest of the page (&quot;Start Date occurs before End Date&quot;). Each type of validation merits its own message. The reason you'd combine these controls is because the integration requires first performing the type validation.</p>
<p>Ideally we could change this at both the client and the server. We can do this with ASP 1.1's validators.</p>
<p>We can set the error message at the client via using the source.errormessage property:</p>
<blockquote>
<p><font face="Courier New" size="2">function ValidateStuff(source, arguments)<br />{ <br />&nbsp;&nbsp;&nbsp; <strong>source.errormessage </strong>= &quot;I changed this on the fly!&quot;; //or source.errormessageB<br />&nbsp;&nbsp;&nbsp; arguments.IsValid = false;<br />}</font></p>
</blockquote>
<p>We can set the error message at the server via casting the source object and setting its ErrorMessage.</p>
<blockquote>
<p><font face="Courier New" size="2">protected void ValidateMaxLength (object source, ServerValidateEventArgs value) <br />{<br />&nbsp;&nbsp;&nbsp; <strong>((CustomValidator)source).ErrorMessage</strong> = &quot;This was changed at the server&quot;;<br />&nbsp;&nbsp;&nbsp; value.IsValid = false;<br />}</font></p>
</blockquote>
<p>We can access the other error message simply by adding a attribute to the current validtor, like ErrorMessageB, and then referencing it like source.errormessageB. Check out <a href="http://timstall.dotnetdevelopersjournal.com/validation_tips_for_validators.htm">Validation Tips for Validators</a> for more details about this. </p>
<p>If you have two error messages, you'll want separate properties for each of those, i.e. have messageA and messageB. Then set source.errormessage to the appropriate one. Don't store your main message in source.errormessage because it will just get overwritten when you set it with something else.</p>
<p>Note that in order for this to show up, the error messages must be displayed in a ValidationSummary control.</p>
<p>A sample custom validator Html might be:</p>
<blockquote>
<p><font face="Courier New" size="2">&lt;asp:ValidationSummary id=&quot;ValidationSummary1&quot; runat=&quot;server&quot;&gt;&lt;/asp:ValidationSummary&gt;<br />...<br />&lt;asp:CustomValidator id=&quot;CustomValidator1&quot; runat=&quot;server&quot; <br />ErrorMessage=&quot;CustomValidator&quot; <br /><strong>ErrorMessage_A = &quot;...&quot;<br />ErrorMessage_B = &quot;...&quot; </strong><br />ControlToValidate=&quot;Text1&quot; <br />ClientValidationFunction=&quot;ValidateDate&quot; <br />OnServerValidate=&quot;ValidateDate&quot;<br />Display=&quot;None&quot;&gt;<br />&lt;/asp:CustomValidator&gt;</font></p>
</blockquote>
<p>This is just another trick for ASP.Net validators to give you some more flexibility.</p>]]></description></item><item><title>DHTML II: Using Hidden Divs instead of Popup windows</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/dhtml_ii_using_hidden_divs_instead_of_popup_windows.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/dhtml_ii_using_hidden_divs_instead_of_popup_windows.htm</link><pubDate>Wed, 30 Nov 2005 20:13:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=dhtml%5Fii%5Fusing%5Fhidden%5Fdivs%5Finstead%5Fof%5Fpopup%5Fwindows</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Previous on DHTML: <a href="http://timstall.dotnetdevelopersjournal.com/dhtml_i_intro_and_positioning_text.htm">DHTML I: Intro and Positioning Text</a></p>
<p>A common UI problem is wanting to display a small amount of information (like a date) that takes a big UI control to generate (like a calendar). The standard solution to this is to make some sort of sub-window where the user has as much real-estate as needed to get that information. Two ways to implement this are (1) a new browser popup window, (2) hidden divs.</p>
<p>Each has their own pros &amp; cons. Popup windows are pretty standard and relatively cross-browser dependable. Recall that you can open a popup like so:</p>
<table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1">
    <tbody>
        <tr>
            <td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote>
            <p><font face="Courier New" size="2">window.open(&quot;Window.aspx&quot;,&quot;Name1&quot;,'toolbar=no,location=no ...'); </font></p>
            </blockquote></td>
        </tr>
    </tbody>
</table>
<p>Popup windows have several disadvantages:</p>
<ul>
    <li>It's hard to get data to and from them (you can pass data to them through the querystring, and from them with the window.opener property, but this is messy). </li>
    <li>You can't control where the user drags them. They can hide them behind other windows, move them all over, max or min them, etc.. To some extent you can pile on the JavaScript to minimize what the user can do, but it gets tedious. </li>
    <li>They open up a whole separate application (i.e. a new browser) </li>
</ul>
<p>A whole different solution is to use a hidden div, and perhaps enclosing an iFrame to present a whole new page. This gives you the benefits of a popup (more temporary real-estate), without the drawbacks.</p>
<p>We can implement this using CSS's visibility style, along <a href="http://timstall.dotnetdevelopersjournal.com/dhtml_i_intro_and_positioning_text.htm">with the positioning attributes</a>. Here's a sample how:</p>
<table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1">
    <tbody>
        <tr>
            <td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote>
            <p><font face="Courier New"><span id="output"><span class="kwrd"><font color="#0000ff" size="2">&lt;</font></span><font size="2"><span class="html"><font color="#800000">html</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">title</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>SimplePopup<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">title</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .divAbsPosition1<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z-index: 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left: 100px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; position:absolute;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; top: 50px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">div</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;DivAbsPosition&quot;</font></span> <span class="attr"><font color="#ff0000">class</font></span><span class="kwrd"><font color="#0000ff">=&quot;divAbsPosition1&quot;</font></span> <span class="attr"><font color="#ff0000">style</font></span><font color="#0000ff"><span class="kwrd">=&quot;COLOR: black&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">table</font></span> <span class="attr"><font color="#ff0000">border</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">bgcolor</font></span>=#<span class="attr"><font color="#ff0000">ffffcc</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">td</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Whatever content you want goes here.<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">td</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">table</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">div</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">input</font></span> <span class="attr"><font color="#ff0000">type</font></span>=<span class="attr"><font color="#ff0000">button</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;Show&quot;</font></span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;document.getElementById('DivAbsPosition').style.visibility='visible'&quot;</font></span> <font color="#0000ff"><span class="kwrd">/&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">input</font></span> <span class="attr"><font color="#ff0000">type</font></span>=<span class="attr"><font color="#ff0000">button</font></span> <span class="attr"><font color="#ff0000">value</font></span><span class="kwrd"><font color="#0000ff">=&quot;Hide&quot;</font></span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="attr"><font color="#ff0000">onclick</font></span><span class="kwrd"><font color="#0000ff">=&quot;document.getElementById('DivAbsPosition').style.visibility='hidden'&quot;</font></span> <font color="#0000ff"><span class="kwrd">/&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">p</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Some normal page content goes here.<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">p</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span> <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">p</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Some normal page content goes here.<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">p</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">html</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
            </blockquote></td>
        </tr>
    </tbody>
</table>
<p>This technique is another great benefit of DHTML. It's very useful when writing your own custom control (such as a dropdown or calendar) or making appropriate popups.</p>]]></description></item><item><title>DHTML I: Intro and Positioning Text</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/dhtml_i_intro_and_positioning_text.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/dhtml_i_intro_and_positioning_text.htm</link><pubDate>Mon, 28 Nov 2005 17:35:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=dhtml%5Fi%5Fintro%5Fand%5Fpositioning%5Ftext</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>HTML is essentially static. However with some JavaScript and CSS, you can make it dynamic - hence <a href="http://www.w3schools.com/dhtml/default.asp">DHTML</a> (D is for Dynamic). There are lots of neat things you can do with DHTML. While some of it may just be for &quot;toys&quot;, some of it can also enhance the UI for an enterprise app.</p>
<p>Using CSS, you can position your text in several ways. First you can set whether the style refer to an absolute or relative position. You can then specify the left or top. You can also specify the &quot;layer&quot; via the Z index. For example, the following snippet offsets the div tag:</p>
<p>
<table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1">
    <tbody>
        <tr>
            <td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote>
            <p><font face="Courier New"><span id="output"><font size="2">&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; .pos1<br />&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; z-index: 1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; left: 100px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; position:absolute;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; top: 20px;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; background-color:Yellow;<br />&nbsp;&nbsp;&nbsp; }<br />&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">style</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">div</font></span> <span class="attr"><font color="#ff0000">class</font></span><font color="#0000ff"><span class="kwrd">=&quot;pos1&quot;&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hello World<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">div</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&nbsp; <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p>
            </blockquote></td>
        </tr>
    </tbody>
</table>
</p>
<p>You can use JavaScript to programmatically change the CSS class as whole, or switch a specific style:</p>
<p>
<table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1">
    <tbody>
        <tr>
            <td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote>
            <p><font face="Courier New" size="2">document.getElementById('DivPosition').className = 'myNewClass';<br />document.getElementById('DivPosition').style.left = 10;</font></p>
            </blockquote></td>
        </tr>
    </tbody>
</table>
</p>
<p>The combination of all these things opens up a lot of possibilities. For example, <a href="http://timstall.dotnetdevelopersjournal.com/implementing_a_timer_in_javascript_with_settimeout.htm">using a JavaScript timer</a>, you could move a div across the page by continually updating the .left property.</p>
<p>The next several posts will dive more into DHTML.</p>]]></description></item><item><title>Implementing a timer in JavaScript with setTimeout</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/implementing_a_timer_in_javascript_with_settimeout.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/implementing_a_timer_in_javascript_with_settimeout.htm</link><pubDate>Tue, 22 Nov 2005 19:14:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=implementing%5Fa%5Ftimer%5Fin%5Fjavascript%5Fwith%5Fsettimeout</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Sometimes you want something cycling in the background to give your page an active feel, like images or text labels updating every 4 seconds. You can do that with the JavaScript setTimeout function. The script below keeps a running clock:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New"><span id="output"><span class="kwrd"><font color="#0000ff" size="2">&lt;</font></span><font size="2"><span class="html"><font color="#800000">html</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>  <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">script</font></span> <span class="attr"><font color="#ff0000">language</font></span>=<span class="attr"><font color="#ff0000">javascript</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    &lt;!--<br />    <span class="kwrd"><font color="#0000ff">function</font></span> SetTime()<br />    {<br />      <span class="kwrd"><font color="#0000ff">var</font></span> s = <span class="kwrd"><font color="#0000ff">new</font></span> Date();<br />      document.getElementById(<span class="str"><font color="#006080">&quot;Span1&quot;</font></span>).innerText = s;<br />    }<br />    <span class="kwrd"><font color="#0000ff">function</font></span> UpdateCycle() {<br />        SetTime();<br />      <b>setTimeout(<span class="str"><font color="#006080">&quot;UpdateCycle()&quot;</font></span>,500);</b><br />    }<br />    <font color="#008000"><span class="rem">//--&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">script</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>  <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">head</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>  <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><span class="kwrd"><font color="#0000ff">=&quot;FlowLayout&quot;</font></span> <span class="attr"><font color="#ff0000">onload</font></span><font color="#0000ff"><span class="kwrd">=&quot;UpdateCycle()&quot;&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>      This is a timer test.<br />      <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">span</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Span1&quot;&gt;&lt;/</font></span><span class="html"><font color="#800000">span</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>  <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">html</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p></blockquote></td></tr></tbody></table><p>This method takes a method to call, and the time (in milliseconds) to wait. The pattern is simple:</p><ol><li>Have the body onload event call the looping function, like UpdateCycle(). This function manages the cycling.</li><li>Have the looping function call whatever action you want, and the setTimeOut method.</li><li>Implement the action method (in this case SetTime) to do whatever action you need.</li></ol><p>You could even make a global variable, increment it in each UpdateCycle, and therefore keep a global counter of how many cycle have passed. You could also have the body onload call an initialization method instead, that method would do start-up initialization, and then call the UpdateCycle method.</p><p>This is a simple JavaScript method to use, but it can have a big return to help certain pages feel more lively.</p>]]></description></item><item><title>HtmlControls vs. WebControls</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/htmlcontrols_vs_webcontrols.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/htmlcontrols_vs_webcontrols.htm</link><pubDate>Tue, 01 Nov 2005 14:46:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=htmlcontrols%5Fvs%5Fwebcontrols</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Plain Html provides form controls via the &lt;input&gt; tag. These are standard controls like textBoxes, dropdowns, and radiobuttons. ASP.Net provides its own version of these controls. Ultimately the ASP.Net version gets rendered as a html. For development you can use either the WebControls or the normal html controls run as server controls. The table below offers some comparisons:</p><p><table id="AutoNumber10" style="BORDER-COLLAPSE: collapse" bordercolor="#111111" cellspacing="0" cellpadding="2" width="100%" border="1"><tbody><tr><td width="10%" bgcolor="#ffffcc"> </td><td width="45%" bgcolor="#ffffcc"><b><font size="2">WebControl</font></b></td><td width="45%" bgcolor="#ffffcc"><b><font size="2">HtmlControl runat=server</font></b></td></tr><tr><td valign="top" width="10%"><font size="2">Description</font></td><td valign="top" width="45%"><font size="2">The ASP.Net controls residing in System.Web.UI.WebControls</font></td><td valign="top" width="45%"><font size="2">Normal html controls that are run at the server. These reside in System.Web.UI.HtmlControls. Setting a HtmLControl to be runat=server does not automatically make it an ASP.Net webControl.</font></td></tr><tr><td valign="top" width="10%"><font size="2">Pro</font></td><td valign="top" width="45%"><ul><li><font size="2">Easier to initially use. For example, automatically works with validators (a disabled Html control doesn't).</font></li><li><font size="2">Many more webControls than htmlControls (such as the dataGrid, validators, and placeHolders)</font></li></ul></td><td valign="top" width="45%"><ul><li><font size="2">Lighter - doesn't have all the extra properties of WebControls</font></li><li><font size="2">Easier to hook up to JavaScript.</font></li></ul></td></tr><tr><td valign="top" width="10%"><font size="2">Con</font></td><td valign="top" width="45%"><ul><li><font size="2">Heavier - has more properties, state, and methods, such as the AutoPostBack. Just compare <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuihtmlcontrolshtmlinputtextmemberstopic.asp">HtmlInputText</a> and <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolstextboxmemberstopic.asp">TextBox</a>.</font></li></ul></td><td valign="top" width="45%"><ul><li><font size="2">Lacks the extra features of WebControls</font></li></ul></td></tr></tbody></table></p><p>The Pros and Cons mean that they each have scenarios where one is better than the other. For cases like textBox and dropdown where both can provide the same control: HtmlControls are good for high performance apps because you use only the functionality that you need, WebControls are good for rapid development because it automatically gives you more stuff (which then must be paid for with performance).</p>]]></description></item><item><title>Using a single html file for easy management</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/using_a_single_html_file_for_easy_management.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/using_a_single_html_file_for_easy_management.htm</link><pubDate>Fri, 28 Oct 2005 14:59:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=using%5Fa%5Fsingle%5Fhtml%5Ffile%5Ffor%5Feasy%5Fmanagement</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>Normally you want to split your html objects (like styles, scripts, and data) into separate files to make things more reusable. However sometimes when you're creating an internal developer report (for status, confirmation, quick info, etc...), it's easier to give the user a single html file than a whole collection of files. For example, suppose you're making an internal WinForms tool that assists with some development task, and then generates an Html status report. As a single file, it's easier to mail to others or copy into different directories,.</p><p>An html page can have several components, each as separate, physical files:</p><ul><li>The main html page itself</li><li>A style sheet</li><li>External JavaScripts</li><li>Inline frames</li><li>Images</li><li>An Xml data source</li></ul><p>We can embed both the style sheet and JavaScript into the head of the main html file itself:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><span id="output"><font size="2"><font face="courier new,courier,monospace"><span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">html</font></span></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">head</font></span></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">title</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Security Rights<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">title</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span></font></font></span></p><p><span id="output"><br /><font size="2"><font face="courier new,courier,monospace"><span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">Style</font></span></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>.TableHeader<br />{<br />    font-weight: bold;<br />    background-color: #FFFFCC;    <br />}<br /><span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">Style</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span></font></font></span></p><p><span id="output"><br /><font size="2"><font face="courier new,courier,monospace"><span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">script</font></span> <span class="attr"><font color="#ff0000">language</font></span>=<span class="attr"><font color="#ff0000">javascript</font></span></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>&lt;!--<br /><span class="kwrd"><font color="#0000ff">function</font></span> DoStuff() {<br />    </font></font><font size="2"><font face="courier new,courier,monospace"><font color="#008000"><span class="rem">//...</span><br /></font>}<br /></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#008000"><span class="rem">//--&gt;</span><br /></font><span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">script</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span></font></font></span></p><p><span id="output"><br /><font size="2"><font face="courier new,courier,monospace"><span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">head</font></span></font></font><font size="2"><font face="courier new,courier,monospace"><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;</span></font><span class="html"><font color="#800000">body</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span></font></font></span></p></blockquote></td></tr></tbody></table><p>We can imitate some features of inline frames via CSS by <a href="/css_tip_scrolling_inline_tables.htm">scrolling inline tables</a>.</p><p>If you're already automatically generating the report, then you've already essentially split data from presentation and therefore you can also hardcode the data directly into the Html itself.</p><p>That leaves us with Images - which I'm not sure of any way to embed images into an Html file.</p><p>However all in all, having the option of putting your styles, scripts, inline frames, and data all into a single file may make it easier to manange for internal reports.</p>]]></description></item><item><title>CSS Tip: Scrolling inline tables</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/css_tip_scrolling_inline_tables.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/css_tip_scrolling_inline_tables.htm</link><pubDate>Wed, 05 Oct 2005 15:44:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=css%5Ftip%5Fscrolling%5Finline%5Ftables</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>A common UI problem is displaying a large amount of information in only a little space. Different user requirements allow for different solutions. For example, perhaps the user has 50 items, but only needs to see 10 at a time. The entire list is still small enough that you can bring all the data to the client - don't need to page through it with a previous/next button doing server hits. Technically, this could be implemented by putting all 50 items in a sub-page, and then displaying that sub-page in the main page <a href="http://www.w3schools.com/html/html_frames.asp">as an inline frame</a>. This would fulfill the user requirements:</p><ul><li>You could set the frame size to be only 10 items.</li><li>All the data is still at the client - so it's quick</li><li>The user can conveniently scroll through the list.</li></ul><p>While this functionally works, it's technically tedious. Having a separate sub-page means extra JavaScript to pass values between the main and sub page (such as when you save and you want to see the item selected). It also means one more page to keep track of. An alternative solution is to <a href="http://www.w3schools.com/css/pr_border-bottom_style.asp">use CSS to inset the table</a> within a <a href="http://www.w3schools.com/tags/tag_div.asp">div region</a>:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New"><span id="output"><font size="2">  <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>This is an inline table test:<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">table</font></span> <span class="attr"><font color="#ff0000">width</font></span><font color="#0000ff"><span class="kwrd">=&quot;100%&quot;&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">tbody</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">td</font></span> <span class="attr"><font color="#ff0000">width</font></span><font color="#0000ff"><span class="kwrd">=&quot;50%&quot;&gt;</span><br /></font>                <b><span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">div</font></span> <span class="attr"><font color="#ff0000">style</font></span><span class="kwrd"><font color="#0000ff">=&quot;BORDER-RIGHT: 1px inset; BORDER-TOP: 1px inset; Z-INDEX: 1; OVERFLOW: auto; BORDER-LEFT: 1px inset; BORDER-BOTTOM: 1px inset; HEIGHT: 100px&quot;&gt;</font></span></b><br />        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TABLE</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Table1&quot;</font></span> <span class="attr"><font color="#ff0000">cellSpacing</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">cellPadding</font></span><span class="kwrd"><font color="#0000ff">=&quot;1&quot;</font></span> <span class="attr"><font color="#ff0000">width</font></span><span class="kwrd"><font color="#0000ff">=&quot;100%&quot;</font></span> <span class="attr"><font color="#ff0000">border</font></span><font color="#0000ff"><span class="kwrd">=&quot;1&quot;&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">tbody</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>aaaaa<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbbbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>ccccc<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>ddddd<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>eeeeeeeeee<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>fffffffff<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>ggggggggg<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>hhhhhh<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>iiiiiiii<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>jjjjjjj<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>kkkkkkkkk<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>llllllllllll<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">TD</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>bbb<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TR</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">tbody</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">TABLE</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <b><span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">div</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span></b><br />          <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">td</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>          <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">td</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>Other stuff<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">td</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">tr</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">tbody</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">table</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><br /></font>      <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>  <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p></blockquote></td></tr></tbody></table><p>This technique is quick to develop, has the same user benefit, and is all around cleaner.</p>]]></description></item><item><title>Anchor onclick vs. Href</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/anchor_onclick_vs_href.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/anchor_onclick_vs_href.htm</link><pubDate>Mon, 03 Oct 2005 15:22:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=anchor%5Fonclick%5Fvs%5Fhref</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>ASPX, including all its &quot;special&quot; features like postbacks and validators, ultimately renders as standard Html. So it's good to understand how certain Html components, like anchors, work. </p><p>A simple anchor just has an target page in the Href, look like so:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="courier new,courier,monospace" size="2">&lt;a href=&quot;PageB.aspx&quot; &gt;AnchorLink&lt;/a&gt;</font></p></blockquote></td></tr></tbody></table><p>Clicking this anchor will always redirect to PageB.aspx. The Href property can also contain a method to call. For example, ASP.Net renders LinkButtons as anchors whose Href calls the postback method:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="courier new,courier,monospace" size="2">&lt;a id=&quot;LinkButton1&quot; <b>href=&quot;javascript:__doPostBack('LinkButton1','')&quot;</b>&gt;LinkButton&lt;/a&gt;</font></p></blockquote></td></tr></tbody></table><p>Anchors can also have an onclick event. You could have this method call a message box, set hidden fields, or do whatever else you needed. <b>However, the Href will not be called if the onclick returns false</b>. For example, you could create a &quot;Do you want to save?&quot; yes-no MessageBox like so:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="courier new,courier,monospace" size="2">&lt;a onclick=&quot;return confirm('Do you want to save')&quot; href=&quot;PageB.aspx&quot;&gt;AnchorLink&lt;/a&gt;</font></p></blockquote></td></tr></tbody></table><p>The JavaScript confirm() method displays a yes-no confirm box, and returns either true or false depending on what the user clicked. Therefore if the user clicks no, the messageBox returns false, and the href is never activated. This concept applies whether the Href contains a navigation page or JavaScript. For example, you could add the confirm box to the LinkButton, and block the postback if the user answered &quot;No&quot; to a certain question.</p><p>Knowing the relationship between the anchor onclick and href lets you develop a more interactive and rich UI.</p>]]></description></item><item><title>Referencing lists of Html controls in Repeaters and DataGrids</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/referencing_lists_of_html_controls_in_repeaters_and_datagrid.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/referencing_lists_of_html_controls_in_repeaters_and_datagrid.htm</link><pubDate>Mon, 08 Aug 2005 21:02:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=referencing%5Flists%5Fof%5Fhtml%5Fcontrols%5Fin%5Frepeaters%5Fand%5Fdatagrid</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[If you have list that you bind to a repeater, and you need to dynamically create html objects for each row (such as adding a checkbox or hidden field for each row). .Net provides ways to cleanly handle those Html controls using the &quot;name&quot; attribute.<p>Note that each html control can have an ID (which must be unique) and a Name (which need not be unique). If you assign your controls a common name attribute, such as giving each checkbox in the repeater rows the name &quot;chkA&quot;, then you can easily access those fields. Say you had the following repeater:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New" size="2">&lt;asp:Repeater id=&quot;Repeater1&quot; runat=&quot;server&quot;&gt;<br />    &lt;ItemTemplate&gt;<br />        &lt;tr&gt;<br />            &lt;td&gt;&lt;input type=&quot;checkbox&quot; name=&quot;ChkA&quot; value=&quot;ABC&quot;&gt;&lt;/td&gt;<br />            &lt;td&gt; ... other columns&lt;/td&gt;<br />        &lt;/tr&gt;<br />    &lt;/ItemTemplate&gt;<br />&lt;/asp:Repeater&gt;</font></p></blockquote></td></tr></tbody></table><p>On the server, you can create an array of the selected values like:</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New" size="2">string[] s = Page.Request[&quot;ChkA&quot;].Split(',');</font></p></blockquote></td></tr></tbody></table><p>On the client, you can access the fields via the document.getElementsByName('name'):</p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New" size="2">function DoClick() {<br />    var v = document.getElementsByName(&quot;ChkA&quot;);<br />    var s = &quot;&quot;;<br />    for (var i = 0; i &lt; v.length; i++) {<br />        if (v[i].checked) {<br />            s = s + v[i].value + &quot;,&quot;;<br />        }<br />    }<br />}</font></p></blockquote></td></tr></tbody></table><p />]]></description></item><item><title>CSS Tip: Using media=print for printer-friendly pages</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/css_tip_using_mediaprint_for_printerfriendly_pages.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/css_tip_using_mediaprint_for_printerfriendly_pages.htm</link><pubDate>Fri, 29 Jul 2005 11:57:00 GMT</pubDate><comments>http://timstall.dotnetdevelopersjournal.com/console/comments/popup/?f=css%5Ftip%5Fusing%5Fmediaprint%5Ffor%5Fprinterfriendly%5Fpages</comments><dc:creator>Tim Stall</dc:creator><description><![CDATA[<p>When you print a page, you want just the workspace of the page in normal portrait view - not banner ads, left navigation bars or text that extends off the printed page . This is a printer-friendly view. There are at least two categories of solutions:</p><ol><li>Have a &quot;click here for printer-friendly version&quot; link that posts back to the server, does manipulation such as hiding menus, and creates a new instance of the page in printer-friendly mode</li><li>Use Cascading Style Sheets (CSS).</li></ol><p>The former has several problems that the latter solves:</p><ul><li>It posts back to the server, which hurts performance</li><li>It becomes a nightmare if you want to open a new instance of the page for printing, such that closing this print-page won't accidentally close the main app page.</li><li>It is a pain for editable pages because it requires the developer to manually persist all values to the new print page. Say the user enters a value in a text field, how do you persist that to a new page instance, perhaps via querystring or session? But what if the values are large?</li><li>It requires additional effort for each page.</li></ul><p>CSS provides a &quot;media&quot; attribute that can apply different style sheets to different media. The two media we're looking at here are <i>screen</i> (default) and <i>print</i>.</p><p>A stylesheet can set the color, visibility, or any other style that's relevant to a print-version. Here's a practical example that hides buttons (you can click a button in printview) and formats all text in greycolor (you many not want to waste color printing on text):</p><p>Html page:</p><p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><font face="Courier New"><span id="output"><span class="kwrd"><font color="#0000ff" size="2">&lt;</font></span><font size="2"><span class="html"><font color="#800000">HTML</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">HEAD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <font color="#008000"><span class="rem">&lt;!-- two different style sheets, 1 for print, 1 for screen --&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">LINK</font></span> <span class="attr"><font color="#ff0000">href</font></span><span class="kwrd"><font color="#0000ff">=&quot;Print.css&quot;</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;text/css&quot;</font></span> <span class="attr"><font color="#ff0000">rel</font></span><span class="kwrd"><font color="#0000ff">=&quot;stylesheet&quot;</font></span> <span class="attr"><font color="#ff0000">media</font></span><font color="#0000ff"><span class="kwrd">=&quot;print&quot;&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">LINK</font></span> <span class="attr"><font color="#ff0000">href</font></span><span class="kwrd"><font color="#0000ff">=&quot;StyleSheet1.css&quot;</font></span> <span class="attr"><font color="#ff0000">type</font></span><span class="kwrd"><font color="#0000ff">=&quot;text/css&quot;</font></span> <span class="attr"><font color="#ff0000">rel</font></span><span class="kwrd"><font color="#0000ff">=&quot;stylesheet&quot;</font></span> <span class="attr"><font color="#ff0000">media</font></span><font color="#0000ff"><span class="kwrd">=&quot;screen&quot;&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">HEAD</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">body</font></span> <span class="attr"><font color="#ff0000">MS_POSITIONING</font></span><font color="#0000ff"><span class="kwrd">=&quot;FlowLayout&quot;&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">form</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Form1&quot;</font></span> <span class="attr"><font color="#ff0000">method</font></span><span class="kwrd"><font color="#0000ff">=&quot;post&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><font color="#0000ff"><span class="kwrd">=&quot;server&quot;&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><span class="kwrd"><font color="#0000ff">&gt;</font></span>This tests styles.<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">asp:Label</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Label1&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><span class="kwrd"><font color="#0000ff">=&quot;server&quot;</font></span> <span class="attr"><font color="#ff0000">CssClass</font></span><font color="#0000ff"><span class="kwrd">=&quot;MainFont&quot;&gt;</span><br /></font>                Label<span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">asp:Label</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>            <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>                <span class="kwrd"><font color="#0000ff">&lt;</font></span><span class="html"><font color="#800000">asp:Button</font></span> <span class="attr"><font color="#ff0000">id</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button1&quot;</font></span> <span class="attr"><font color="#ff0000">runat</font></span><span class="kwrd"><font color="#0000ff">=&quot;server&quot;</font></span> <span class="attr"><font color="#ff0000">CssClass</font></span><span class="kwrd"><font color="#0000ff">=&quot;PrintButton&quot;</font></span> <br />                <span class="attr"><font color="#ff0000">Text</font></span><span class="kwrd"><font color="#0000ff">=&quot;Button&quot;&gt;&lt;/</font></span><span class="html"><font color="#800000">asp:Button</font></span><span class="kwrd"><font color="#0000ff">&gt;&lt;/</font></span><span class="html"><font color="#800000">P</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>        <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">form</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /></font>    <span class="kwrd"><font color="#0000ff">&lt;/</font></span><span class="html"><font color="#800000">body</font></span><font color="#0000ff"><span class="kwrd">&gt;</span><br /><span class="kwrd">&lt;/</span></font><span class="html"><font color="#800000">HTML</font></span></font><span class="kwrd"><font color="#0000ff" size="2">&gt;</font></span></span></font></p></blockquote></td></tr></tbody></table></p><p>Stylesheet (Normal):</p><p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><span id="output"><font face="Courier New" size="2">body<br />{<br />}<br />.MainFont<br />{<br />    font-weight: bold;<br />    color: red;<br />}</font></span></p></blockquote></td></tr></tbody></table></p><p>Stylesheet (Print):</p><p><table id="AutoNumber3" style="BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-COLLAPSE: collapse; BORDER-RIGHT-WIDTH: 0px" bordercolor="#111111" cellpadding="2" width="100%" border="1"><tbody><tr><td style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-BOTTOM: medium none" width="100%"><blockquote><p><span id="output"><font face="Courier New" size="2">body<br />{<br />}<br />.PrintButton<br />{<br />    display: none;<br />}<br />.Template <br />{<br />    display: none;<br />}</font></span></p></blockquote></td></tr></tbody></table></p><p>Eric Myer has a great article that explains how to <a href="http://www.meyerweb.com/eric/articles/webrev/200001.html">use CSS for printing</a>.</p>]]></description></item><item><title>Overlapping Server and embedded &amp;lt;% %&amp;gt; tags.</title><guid isPermaLink="true">http://timstall.dotnetdevelopersjournal.com/overlapping_server_and_embedded_lt_gt_tags.htm</guid><link>http://timstall.dotnetdevelopersjournal.com/overlapping_server_and_embedded_lt_gt_tags.htm</link><pubDate>Wed, 20 Jul 2005 11:15:00 GMT</pubDate><comments>http://timstall.dotnetdevelopers