<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3409122642905288931</id><updated>2024-09-13T15:50:45.810+08:00</updated><title type='text'>Tech-Lifes - Programming &amp; Database</title><subtitle type='html'>Sharing programming and database problem with you, especially in .NET programming, Javascript and SQL Server 2000.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-1367882826852702897</id><published>2007-11-04T20:16:00.000+08:00</published><updated>2007-11-05T17:48:43.451+08:00</updated><title type='text'>JavaScript Count Up Timer with Source Code using Interval() Method</title><content type='html'>Try this count up timer.&lt;br /&gt;&lt;input type=&quot;button&quot; name=&quot;btnCountUp&quot; value=&quot;Start&quot; onClick=&quot;startStopCountUp();&quot; ID=&quot;btnCountUp&quot;&gt;&lt;input type=&quot;button&quot; name=&quot;btnReset&quot; value=&quot;Reset&quot; onClick=&quot;ResetCountUp();&quot; ID=&quot;btnReset&quot; style=&quot;DISPLAY:none&quot;&gt;&lt;br /&gt;&lt;span id=&quot;spanTimer&quot; style=&quot;font-size: 20px; color: orange;&quot;&gt;00:00:00:000&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The source code is like below:&lt;div style=&quot;OVERFLOW: auto; WIDTH: 100%&quot;&gt;&lt;table width=&quot;100%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;   var myInterval;&lt;br /&gt;   var count = 0;&lt;br /&gt;   var startTime;&lt;br /&gt;&lt;br /&gt;   function startStopCountUp()&lt;br /&gt;   {&lt;br /&gt;      if (document.getElementById(&quot;btnReset&quot;).style.display == &#39;none&#39;)&lt;br /&gt;      {&lt;br /&gt;         document.getElementById(&quot;btnReset&quot;).style.display = &#39;&#39;;&lt;br /&gt;      }&lt;br /&gt;      if (document.getElementById(&quot;btnCountUp&quot;).value == &quot;Pause&quot;)&lt;br /&gt;      {&lt;br /&gt;         StopCountUp();&lt;br /&gt;         document.getElementById(&quot;btnCountUp&quot;).value = &quot;Resume&quot;;&lt;br /&gt;      }&lt;br /&gt;      else&lt;br /&gt;      {&lt;br /&gt;         startTime = new Date();&lt;br /&gt;         myInterval = window.setInterval(&#39;StartCountUp()&#39;,333);&lt;br /&gt;         document.getElementById(&quot;btnCountUp&quot;).value = &quot;Pause&quot;;  &lt;br /&gt;      }  &lt;br /&gt;   }&lt;br /&gt;  &lt;br /&gt;   function StartCountUp()&lt;br /&gt;   {&lt;br /&gt;      var myDate = new Date();&lt;br /&gt;      count = myDate - startTime + count;&lt;br /&gt;      startTime = myDate;&lt;br /&gt;  &lt;br /&gt;      spanTimer.innerHTML = showDiffTime(count);&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   function StopCountUp()&lt;br /&gt;   {&lt;br /&gt;      window.clearInterval(myInterval);&lt;br /&gt;   }&lt;br /&gt; &lt;br /&gt;   function ResetCountUp()&lt;br /&gt;   {&lt;br /&gt;      StopCountUp();&lt;br /&gt;      document.getElementById(&quot;btnCountUp&quot;).value = &quot;Start&quot;;  &lt;br /&gt;      document.getElementById(&quot;btnReset&quot;).style.display = &#39;none&#39;;&lt;br /&gt;      count = 0;&lt;br /&gt;      spanTimer.innerHTML = &#39;0&#39;;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   function showDiffTime(diffTime)&lt;br /&gt;   {&lt;br /&gt;      var miliseconds = diffTime % 1000;&lt;br /&gt;      var scratch = Math.floor((diffTime - miliseconds) / 1000);&lt;br /&gt;      var seconds = scratch % 60;&lt;br /&gt;      scratch = Math.floor((scratch - seconds) / 60);&lt;br /&gt;      var minutes = scratch % 60;&lt;br /&gt;      scratch = Math.floor((scratch - minutes) / 60);&lt;br /&gt;      var hours = scratch % 24;&lt;br /&gt;      scratch = Math.floor((scratch - hours) / 24);&lt;br /&gt;      var days = scratch;&lt;br /&gt;  &lt;br /&gt;      var displayDiffTime = &quot;&quot;&lt;br /&gt;  &lt;br /&gt;      if (days &gt; 0)&lt;br /&gt;         displayDiffTime += days + &#39; days, &#39;;&lt;br /&gt;   &lt;br /&gt;      if (hours &gt; 9)&lt;br /&gt;         displayDiffTime += hours + &#39;:&#39;;&lt;br /&gt;      else&lt;br /&gt;         displayDiffTime += &#39;0&#39; + hours + &#39;:&#39;;&lt;br /&gt;   &lt;br /&gt;      if (minutes &gt; 9)&lt;br /&gt;         displayDiffTime += minutes + &#39;:&#39;;&lt;br /&gt;      else&lt;br /&gt;         displayDiffTime += &#39;0&#39; + minutes + &#39;:&#39;; &lt;br /&gt;  &lt;br /&gt;      if (seconds &gt; 9)&lt;br /&gt;         displayDiffTime += seconds + &#39;:&#39;;&lt;br /&gt;      else&lt;br /&gt;         displayDiffTime += &#39;0&#39; + seconds + &#39;:&#39;; &lt;br /&gt;   &lt;br /&gt;      if (miliseconds &gt; 99)&lt;br /&gt;         displayDiffTime += miliseconds;&lt;br /&gt;      else if (miliseconds &gt; 9)&lt;br /&gt;         displayDiffTime += &#39;0&#39; + miliseconds;&lt;br /&gt;      else&lt;br /&gt;         displayDiffTime += &#39;00&#39; + miliseconds;   &lt;br /&gt;      return displayDiffTime;&lt;br /&gt;   }&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; name=&quot;btnCountUp&quot; value=&quot;Start&quot; onClick=&quot;startStopCountUp();&quot; ID=&quot;btnCountUp&quot;&amp;gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; name=&quot;btnReset&quot; value=&quot;Reset&quot; onClick=&quot;ResetCountUp();&quot; ID=&quot;btnReset&quot; style=&quot;DISPLAY:none&quot;&amp;gt;&lt;br /&gt;&amp;lt;span id=&quot;spanTimer&quot; style=&quot;font-size: 20px; color: orange;&quot;&amp;gt;00:00:00:000&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/1367882826852702897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/1367882826852702897' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/1367882826852702897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/1367882826852702897'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/11/javascript-count-up-timer-with-source.html' title='JavaScript Count Up Timer with Source Code using Interval() Method'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-4915224086342947540</id><published>2007-10-31T15:57:00.000+08:00</published><updated>2007-11-06T21:51:34.251+08:00</updated><title type='text'>JavaScript Timers with setTimeout and setInterval Methods</title><content type='html'>Here, i would like to share with you how to use the JavaScript&#39;s &lt;code&gt;settimeout()&lt;/code&gt;, &lt;code&gt;clearTimeout()&lt;/code&gt;, &lt;code&gt;setInterval()&lt;/code&gt; and &lt;code&gt;clearinterval()&lt;/code&gt; methods to set timers and create delayed actions.&lt;br /&gt;&lt;br /&gt;&lt;code style=&quot;font-size:18px&quot;&gt;&lt;u&gt;&lt;strong&gt;setTimeout()&lt;/strong&gt;&lt;/u&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The general syntax of &lt;code&gt;window.setTimeout()&lt;/code&gt; method is:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;setTimeout(&lt;i&gt;expression, timeout&lt;/i&gt;);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;where &lt;code&gt;&lt;i&gt;expression&lt;/i&gt;&lt;/code&gt; is the JavaScript code to run after &lt;code&gt;&lt;i&gt;timeout&lt;/i&gt;&lt;/code&gt; miliseconds have elapsed.&lt;br /&gt;&lt;code&gt;setTimeout()&lt;/code&gt; return a numeric timeout ID that can be used to track the timeout. This is most commonly used with the &lt;code&gt;clearTimeout()&lt;/code&gt; method.&lt;br /&gt;After &lt;code&gt;setTimeout()&lt;/code&gt; is called, execution of the following script will continue normally. The expression in &lt;code&gt;setTimeout()&lt;/code&gt; will be run when pass the timeout period.&lt;br /&gt;&lt;br /&gt;For example, the following code sets up an alert box to appear after 3 seconds and disable the button when a button is clicked. After 3 seconds, the alert appears. When click the [ok] button of the alert, the button will enable again.&lt;br /&gt;&lt;div style=&quot;OVERFLOW: auto; WIDTH: 100%&quot;&gt;&lt;table width=&quot;100%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;function alertClickHandler()&lt;br /&gt;{&lt;br /&gt;   setTimeout(&#39;showAlert()&#39;, 3000);     &lt;br /&gt;   document.getElementById(&quot;btnClickMe&quot;).disabled = true;    &lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function showAlert()&lt;br /&gt;{&lt;br /&gt;   alert(&#39;3 seconds time out&#39;);&lt;br /&gt;   document.getElementById(&quot;btnClickMe&quot;).disabled = false;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; name=&quot;btnClickMe&quot; id=&quot;btnClickMe&quot; value=&quot;Click me&quot; onclick=&quot;alertClickHandler();&quot; /&amp;gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;Try it! Click the button below and wait 3 seconds.&lt;br /&gt;&lt;br /&gt;&lt;input type=&quot;button&quot; name=&quot;btnClickMe&quot; id=&quot;btnClickMe&quot; value=&quot;Click me&quot; onclick=&quot;alertClickHandler();&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code style=&quot;font-size:18px&quot;&gt;&lt;u&gt;&lt;strong&gt;clearTimeout()&lt;/strong&gt;&lt;/u&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The &lt;code&gt;window.clearTimeout()&lt;/code&gt; method is used to cancel a timer before it goes off. It&#39;s syntax is:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;clearTimeout(&lt;i&gt;timeoutId&lt;/i&gt;);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;where &lt;code&gt;&lt;i&gt;timeoutId&lt;/i&gt;&lt;/code&gt; is the timeout ID returned from the setTimeout() method call.&lt;br /&gt;&lt;br /&gt;For example, the following code sets up an alert box to appear after 3 seconds when a button is clicked, but the visitor can click the same button before the alert appears and cancel the timeout.&lt;br /&gt;&lt;div style=&quot;OVERFLOW: auto; WIDTH: 100%&quot;&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;var timeoutID = 0;&lt;br /&gt;&lt;br /&gt;function alertTimerClickHandler()&lt;br /&gt;{&lt;br /&gt;   if (document.getElementById(&quot;btnClick&quot;).value == &quot;Try click me!&quot;)&lt;br /&gt;   {&lt;br /&gt;      timeoutID = setTimeout(&#39;showAlertTimer()&#39;, 3000);&lt;br /&gt;      document.getElementById(&quot;btnClick&quot;).value = &quot;Click me to stop the timer!&quot;;&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;   {&lt;br /&gt;      clearTimeout(timeoutID);&lt;br /&gt;      document.getElementById(&quot;btnClick&quot;).value = &quot;Try click me!&quot;;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function showAlertTimer()&lt;br /&gt;{&lt;br /&gt;   alert(&#39;Time out! You did not stop the timer.&#39;);&lt;br /&gt;   document.getElementById(&quot;btnClick&quot;).value = &quot;Try click me!&quot;;   &lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; name=&quot;btnClick&quot; id=&quot;btnClick&quot; value=&quot;Try click me!&quot; onclick=&quot;alertTimerClickHandler();&quot; /&amp;gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;Try it! Click the button below to start the timer and click it again within 3 seconds to cancel it.&lt;br /&gt;&lt;br /&gt;&lt;input type=&quot;button&quot; name=&quot;btnClick&quot; id=&quot;btnClick&quot; value=&quot;Try click me!&quot; onclick=&quot;alertTimerClickHandler();&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code style=&quot;font-size:18px&quot;&gt;&lt;u&gt;&lt;strong&gt;setInterval()&lt;/strong&gt;&lt;/u&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The &lt;code&gt;setInterval()&lt;/code&gt; function is very same to &lt;code&gt;setTimeout()&lt;/code&gt; even the their syntax is similar. It&#39;s syntax is:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;setInterval(&lt;i&gt;expression, interval&lt;/i&gt;);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;The difference is &lt;code&gt;setTimeout()&lt;/code&gt; triggers &lt;code&gt;&lt;i&gt;expression&lt;/i&gt;&lt;/code&gt; only once but &lt;code&gt;setInterval()&lt;/code&gt; keeps triggering &lt;code&gt;&lt;i&gt;expression&lt;/i&gt;&lt;/code&gt; again and again unless stop it.&lt;br /&gt;&lt;br /&gt;&lt;code style=&quot;font-size:18px&quot;&gt;&lt;u&gt;&lt;strong&gt;clearInterval()&lt;/strong&gt;&lt;/u&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If want to cancel a &lt;code&gt;setInterval()&lt;/code&gt;, call &lt;code&gt;clearInterval()&lt;/code&gt; method. It&#39;s syntax is like below:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;clearInterval(&lt;i&gt;intervalId&lt;/i&gt;);&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;where &lt;code&gt;&lt;i&gt;intervalId&lt;/i&gt;&lt;/code&gt; is the interval ID returned from the setInterval() method call.&lt;br /&gt;&lt;br /&gt;Here&#39;s a simple example using both &lt;code&gt;setInterval()&lt;/code&gt; and &lt;code&gt;clearInterval&lt;/code&gt;. When visitor click the button at below, the following code start to count up and display it until visitor click the button again to stop it.&lt;br /&gt;&lt;div style=&quot;OVERFLOW: auto; WIDTH: 100%&quot;&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&lt;pre&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;var intervalID = 0;&lt;br /&gt;var count = 0;&lt;br /&gt;&lt;br /&gt;function startCountUp()&lt;br /&gt;{&lt;br /&gt;   if (document.getElementById(&quot;btnClickInterval&quot;).value != &quot;Stop count up!&quot;)&lt;br /&gt;   {&lt;br /&gt;      document.getElementById(&quot;divCount&quot;).innerHTML = count;&lt;br /&gt;      intervalID = setInterval(&#39;displayCountUp()&#39;, 1000);      &lt;br /&gt;      document.getElementById(&quot;btnClickInterval&quot;).value = &quot;Stop count up!&quot;;&lt;br /&gt;   }&lt;br /&gt;   else&lt;br /&gt;   {&lt;br /&gt;      clearInterval(intervalID);&lt;br /&gt;      count = 0;&lt;br /&gt;      document.getElementById(&quot;btnClickInterval&quot;).value = &quot;Restart count up!&quot;;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function displayCountUp()&lt;br /&gt;{&lt;br /&gt;   count += 1;&lt;br /&gt;   document.getElementById(&quot;divCount&quot;).innerHTML = count;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div id=&quot;divCount&quot; style=&quot;font-size: 20px; color: orange;&quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;lt;input type=&quot;button&quot; name=&quot;btnClickInterval&quot; id=&quot;btnClickInterval&quot; value=&quot;Start count up!&quot; onclick=&quot;startCountUp();&quot; /&amp;gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Try it! Click the button below to start count up and click it again to stop it.&lt;br /&gt;&lt;br /&gt;&lt;div id=&quot;divCount&quot; style=&quot;font-size: 20px; color: orange;&quot;&gt;0&lt;/div&gt;&lt;br /&gt;&lt;input type=&quot;button&quot; name=&quot;btnClickInterval&quot; id=&quot;btnClickInterval&quot; value=&quot;Start count up!&quot; onclick=&quot;startCountUp();&quot; /&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/4915224086342947540/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/4915224086342947540' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4915224086342947540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4915224086342947540'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/10/javascript-timers-with-settimeout-and.html' title='JavaScript Timers with &lt;code&gt;setTimeout&lt;/code&gt; and &lt;code&gt;setInterval&lt;/code&gt; Methods'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-5117392944228599392</id><published>2007-10-24T21:43:00.000+08:00</published><updated>2007-10-25T11:05:06.189+08:00</updated><title type='text'>Import Data from Excel File using VB .NET</title><content type='html'>The following is the sample code how to query an Excel spreadsheet from an &lt;b&gt;ASP.NET&lt;/b&gt; page using &lt;b&gt;VB .NET&lt;/b&gt;:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;Dim strConn As String&lt;br /&gt;Dim da As OleDbDataAdapter&lt;br /&gt;Dim ds As New DataSet&lt;br /&gt;&lt;br /&gt;strConn = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; &amp; _ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Data Source=C:\test.xls;Extended Properties=&quot;&quot;Excel 8.0;&quot;&quot;&quot;&lt;br /&gt;da = New OleDbDataAdapter(&quot;SELECT * FROM [Sheet1$]&quot;, strConn)&lt;br /&gt;da.TableMappings.Add(&quot;Table&quot;, &quot;Excel&quot;)&lt;br /&gt;da.Fill(ds)&lt;br /&gt;&lt;br /&gt;dataGrid1.DataSource = ds.Tables(0).DefaultView&lt;br /&gt;dataGrid1.DataBind()&lt;br /&gt;da.Dispose()&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&amp;nbsp;The code above is just select data from Sheet1(Worksheet) only.&lt;br /&gt;&lt;br /&gt;If you want to select data from &lt;b&gt;first sheet&lt;/b&gt; in the Excel workbook, need to get the name of the first sheet first.&lt;br /&gt;To get the name of the first sheet in the Excel workbook, refer code below: &lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;Dim dao_dbE As dao.DBEngine&lt;br /&gt;Dim dao_DB As DAO.Database&lt;br /&gt;Dim strFirstSheetName As String&lt;br /&gt;&lt;br /&gt;dao_dbE = New dao.DBEngine&lt;br /&gt;dao_DB = dao_dbE.OpenDatabase(&quot;C:\test.xls&quot;, False, True, &quot;Excel 8.0;&quot;)&lt;br /&gt;strFirstSheetName = dao_DB.TableDefs(0).Name&lt;br /&gt;da0_DB.Close()&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&amp;nbsp;Using code above &lt;b&gt;Microsoft DAO 3.5 Library&lt;/b&gt; is needed. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;nbsp;&amp;nbsp;From the &lt;b&gt;Project&lt;/b&gt; menu, click &lt;b&gt;References&lt;/b&gt;, click &lt;b&gt;Add Reference...&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;and then select the &lt;b&gt;Microsoft DAO 3.5 Library&lt;/b&gt; to add it.&lt;br /&gt;&lt;br /&gt;So, complete code should like below:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;Dim strConn As String&lt;br /&gt;Dim da As OleDbDataAdapter&lt;br /&gt;Dim ds As New DataSet&lt;br /&gt;Dim dao_dbE As dao.DBEngine&lt;br /&gt;Dim dao_DB As DAO.Database&lt;br /&gt;Dim strFirstSheetName As String&lt;br /&gt;&lt;br /&gt;dao_dbE = New dao.DBEngine&lt;br /&gt;dao_DB = dao_dbE.OpenDatabase(&quot;C:\test.xls&quot;, False, True, &quot;Excel 8.0;&quot;)&lt;br /&gt;strFirstSheetName = dao_DB.TableDefs(0).Name&lt;br /&gt;strConn = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; &amp; _ &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Data Source=C:\test.xls;Extended Properties=&quot;&quot;Excel 8.0;&quot;&quot;&quot;&lt;br /&gt;&lt;br /&gt;da = New OleDbDataAdapter(&quot;SELECT * FROM [&quot; &amp; _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;strFirstSheetName &amp; &quot;]&quot;, strConn)&lt;br /&gt;da.TableMappings.Add(&quot;Table&quot;, &quot;Excel&quot;)&lt;br /&gt;da.Fill(ds)&lt;br /&gt;&lt;br /&gt;dataGrid1.DataSource = ds.Tables(0).DefaultView&lt;br /&gt;dataGrid1.DataBind()&lt;br /&gt;&lt;br /&gt;da.Dispose()&lt;br /&gt;da0_DB.Close()&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;Good Luck!!!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/5117392944228599392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/5117392944228599392' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/5117392944228599392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/5117392944228599392'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/10/import-data-from-excel-file-using-vb.html' title='Import Data from Excel File using VB .NET'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-4164381595615395781</id><published>2007-10-20T23:27:00.000+08:00</published><updated>2007-10-23T13:25:19.885+08:00</updated><title type='text'>User.Identity.Name Returns Empty String in ASP .NET</title><content type='html'>If you try to get currently logged on user name with &lt;b&gt;User.Identity.Name&lt;/b&gt;in ASP.NET, but the return value is empty string.&lt;br&gt;The following is syntax accesses this variable in C# .NET:&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;string strUserName = User.Identity.Name;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;This problem occurs because if you use Anonymous Access security to access the .aspx page. This problem can also occurs if you give the Anonymous user access in the &lt;b&gt;&amp;lt;authorization&amp;gt;&lt;/b&gt; section of the Web.config file.&lt;br&gt;&lt;br&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;br&gt;Check the &lt;b&gt;authentication mode&lt;/b&gt; in the Web.config file.&lt;br&gt;&lt;br&gt;If the &lt;b&gt;authentication mode&lt;/b&gt; is &lt;b&gt;Forms-based authentication&lt;/b&gt;:&lt;br&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&amp;lt;authentication mode=&quot;Forms&quot; /&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;To solve this problem just deny access to the Anonymous user in the Web.config file, user the following syntax:&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&amp;lt;authorization&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;deny users = &quot;?&quot; /&amp;gt; &amp;lt;!-- This denies access to the Anonymous user --&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;allow users = &quot;*&quot; /&amp;gt; &amp;lt;!-- This allows access to all users --&amp;gt;&lt;br&gt;&amp;lt;/authorization&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;If the &lt;b&gt;authentication mode&lt;/b&gt; is &lt;b&gt;Windows-based authentication&lt;/b&gt;:&lt;br&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&amp;lt;authentication mode=&quot;Windows&quot; /&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;To solve this problem, use the following steps:&lt;br&gt;&lt;br /&gt;&lt;table width=&quot;95%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;1. Go to Internet Services Manager, right-click the .aspx file or the Web Project folder, and then click &lt;b&gt;Properties&lt;/b&gt;.&lt;br&gt;2. If you clicked &lt;b&gt;Properties&lt;/b&gt; for the Web Project folder, click the &lt;b&gt;Directory Security&lt;/b&gt; tab. If you clicked &lt;b&gt;Properties&lt;/b&gt; for the .aspx file, click the &lt;b&gt;File Security&lt;/b&gt; tab.&lt;br&gt;3. Under &lt;b&gt;Anonymous Access and authentication control&lt;/b&gt;, click &lt;b&gt;Edit&lt;/b&gt;.&lt;br&gt;4. In the &lt;b&gt;Authentication methods&lt;/b&gt; dialog boc, clear the &lt;b&gt;Anonymous Access&lt;/b&gt; check box, and then select either the&lt;b&gt;Basic&lt;/b&gt;, the &lt;b&gt;Digist&lt;/b&gt; or the &lt;b&gt;Integrated (NT Challenge/Response)&lt;/b&gt; check box.&lt;br&gt;6. Click &lt;b&gt;OK&lt;/b&gt; to close both dialog boxes.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;&lt;table width=&quot;100%&quot; align=&quot;center&quot;&gt;&lt;tr align=&quot;center&quot;&gt;&lt;td&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2l4VFHuNaJ7kr_KrHDcJnr28jGZo7PuaPLU-razAPK3tV1rMbSlZ10CIISR1uuw0U7sDZIEsDwVARg_xZ_Q9MWFhAfB47kXx2H_yKL30iH1jjm3O94DNk0pLCySFsH2RP6BUAwieWFCA/s1600-h/Directory+Security.bmp&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2l4VFHuNaJ7kr_KrHDcJnr28jGZo7PuaPLU-razAPK3tV1rMbSlZ10CIISR1uuw0U7sDZIEsDwVARg_xZ_Q9MWFhAfB47kXx2H_yKL30iH1jjm3O94DNk0pLCySFsH2RP6BUAwieWFCA/s320/Directory+Security.bmp&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5123443262136999074&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr align=&quot;center&quot;&gt;&lt;td&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7N7OUxT5D9vn7uLUBhNXehe_eE3SB1PkGZ85fV0Me_w9o2vl3qMLlhLWU0BC-yFcmsJpaueIIE-ak5HLjVotybuF_T555g9T47RErxh0BfUj0C8oAcrOH63f4WvvwmAz1emHWh8C2-w0/s1600-h/Authentication.bmp&quot;&gt;&lt;img style=&quot;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7N7OUxT5D9vn7uLUBhNXehe_eE3SB1PkGZ85fV0Me_w9o2vl3qMLlhLWU0BC-yFcmsJpaueIIE-ak5HLjVotybuF_T555g9T47RErxh0BfUj0C8oAcrOH63f4WvvwmAz1emHWh8C2-w0/s320/Authentication.bmp&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5123443262136999090&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/4164381595615395781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/4164381595615395781' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4164381595615395781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4164381595615395781'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/10/useridentityname-returns-empty-string.html' title='User.Identity.Name Returns Empty String in ASP .NET'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2l4VFHuNaJ7kr_KrHDcJnr28jGZo7PuaPLU-razAPK3tV1rMbSlZ10CIISR1uuw0U7sDZIEsDwVARg_xZ_Q9MWFhAfB47kXx2H_yKL30iH1jjm3O94DNk0pLCySFsH2RP6BUAwieWFCA/s72-c/Directory+Security.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-8877941635762694712</id><published>2007-10-19T23:37:00.001+08:00</published><updated>2007-10-20T00:24:04.115+08:00</updated><title type='text'>Calling Javascript Function from Code Behind(.vb)</title><content type='html'>This is the function at html page:&lt;br&gt;&lt;br /&gt;&lt;table width=&quot;80%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&amp;lt;script language=&quot;javascript&quot;&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;function test(){&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Add the function code here&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;&amp;lt;/script&amp;gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br&gt;To call this javascript function from code behind(.vb), Use &lt;b&gt;Page.RegisterStartupScript&lt;/b&gt;function like the following code:&lt;br&gt;&lt;br /&gt;&lt;table width=&quot;80%&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;Dim strScript As string = &quot;&amp;lt;script language=&#39;javascript&#39; id=&#39;myClientScript&#39;&amp;gt;test();&amp;lt;/script&amp;gt;&quot;&lt;br&gt;Page.RegisterStartupScript(&quot;callTest&quot;, strScript)&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/8877941635762694712/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/8877941635762694712' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/8877941635762694712'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/8877941635762694712'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/10/calling-javascript-function-from-code.html' title='Calling Javascript Function from Code Behind(.vb)'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-1674867741821164165</id><published>2007-09-03T17:10:00.000+08:00</published><updated>2007-09-03T17:26:48.507+08:00</updated><title type='text'>.NET Web Service error - &quot;The request failed with HTTP status 401: Access Denied.&quot;</title><content type='html'>This happen when try to call a Web service application and Anonymous access authentication is turned off.&lt;br /&gt;You can solve this problem by using the &lt;b&gt;Credentials&lt;/b&gt; property of the Web service client proxy to set the security credentials for Web service client authentication. &lt;br /&gt;Assign the &lt;b&gt;DefaultCredentials&lt;/b&gt; to the &lt;b&gt;Credentials&lt;/b&gt; property of the &lt;b&gt;Web Service Proxy&lt;/b&gt; class to call the Web service while Anonymous access authentication is turned off. See the following code:&lt;br /&gt;&lt;table&gt;&lt;tr&gt;&lt;td bgcolor=#d3d3d3&gt;&amp;nbsp;&amp;nbsp;//Assigning DefaultCredentials to the Credentials property&lt;br /&gt;&amp;nbsp;&amp;nbsp;//of the Web service client proxy(ws)&lt;br /&gt;&amp;nbsp;&amp;nbsp;ws.Credentials = System.Net.CredentialCache.DefaultCredentials&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/1674867741821164165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/1674867741821164165' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/1674867741821164165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/1674867741821164165'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/09/web-service-error-request-failed-with.html' title='.NET Web Service error - &quot;The request failed with HTTP status 401: Access Denied.&quot;'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-7864943239540477705</id><published>2007-08-31T12:12:00.000+08:00</published><updated>2007-09-03T17:24:39.868+08:00</updated><title type='text'>.NET Web Service error - &quot;The test form is only available for requests from the local machine&quot;</title><content type='html'>I faced this error before.&lt;br&gt;I used my local pc&#39;s window service application to call a web service function at server (different pc) but it is fail. It cannot work like when I used the same window service application to call the same web service function at local pc.&lt;br&gt;&lt;br /&gt;Then, I tried to browse to the web service through ie. When I click the fuction, it showed the message - &lt;b&gt;&quot;The test form is only available for requests from the local machine&quot;&lt;/b&gt;&lt;br /&gt;&lt;br&gt;After that, I found the solution to fix it. I just added in some code inside the &lt;br /&gt;web.config file then the this problem is solved. The code I added in is like below:&lt;br /&gt;&lt;br&gt;&amp;lt;configuration&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;lt;system.web&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;webServices&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;protocols&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;add name=&quot;HttpGet&quot;/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;add name=&quot;HttpPost&quot;/&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/protocols&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/webServices&amp;gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;lt;/system.web&amp;gt;&lt;br&gt;&amp;lt;/configuration&amp;gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/7864943239540477705/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/7864943239540477705' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/7864943239540477705'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/7864943239540477705'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/08/web-service-error-test-form-is-only.html' title='.NET Web Service error - &quot;The test form is only available for requests from the local machine&quot;'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-4250546411966413645</id><published>2007-07-26T10:54:00.000+08:00</published><updated>2007-07-28T00:05:26.146+08:00</updated><title type='text'>SQL Server function for datetime - DATEADD</title><content type='html'>DATEADD is a date function will return a datetime value based on the number interval add to the particular date part of the specified date. The syntax DATEADD is like:&lt;br /&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td bgcolor=&quot;#dddddd&quot;&gt;DATEADD(date_part, number_interval, specified_date)&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;date_part is the parameter that specifies on which part of the date to be manipulated with the number interval. You can add month, year, day and etc. You can use &lt;table bgcolor=&quot;#dddddd&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;MONTH, MM or M for month&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;YEAR, YYYY, YY for year&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;DAY, DD, D for day&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;HH for hour&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SS, S for Second&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;For example : &lt;table bgcolor=&quot;#dddddd&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;SELECT DATEADD(D, -1, GETDATE())AS [Yesterday]&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SELECT DATEADD(MM, 3, GETDATE())AS [FourMonthsFromNow]&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;SELECT DATEADD(YEAR, -2, GETDATE())AS [TwoYearsAgo]&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/4250546411966413645/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/4250546411966413645' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4250546411966413645'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/4250546411966413645'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/07/sql-server-function-for-datetime-and.html' title='SQL Server function for datetime - DATEADD'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3409122642905288931.post-8092568566523409847</id><published>2007-07-23T17:11:00.000+08:00</published><updated>2007-07-25T15:57:01.142+08:00</updated><title type='text'>Window Service timer problem - VB.NET</title><content type='html'>I wrote a Windows Service application in VB.NET before and i faced a problem. I used timer to do the schedule task in this application. I dropped a Timer Control on the designer then add the Tick event to do the schedule task. I can built, install, stop and restart the service. However the problem is it the Tick event never fires at all.&lt;br /&gt;&lt;br /&gt;After that, i try to use code to create the timer. I changed to use System.Timers.Timer instead of System.Windows.Forms.Timer dropped on the designer from Toolbox. Then it is work already. The code is like below:-&lt;br /&gt;&lt;br /&gt;Dim timerSchedule As System.Timers.Timer&lt;br /&gt;&lt;br /&gt;Protected Overrides Sub OnStart(ByVal args() As String)&lt;br /&gt;timerSchedule = New System.Timers.Timer(1000)&lt;br /&gt;AddHandler timerSchedule.Elapsed, AddressOf timerSchedule_Elapsed timerSchedule.Start() End Sub&lt;br /&gt;&lt;br /&gt;Private Sub timerSchedule_Elapsed(ByVal pSender As Object, ByVal pArgs As System.Timers.ElapsedEventArgs)&lt;br /&gt;Try timerSchedule.Stop()&lt;br /&gt;&#39;call my a function to do the scheduled task&lt;br /&gt;DoScheduledTask()&lt;br /&gt;Catch ex As Exception&lt;br /&gt;Finally&lt;br /&gt;timerSchedule.Start()&lt;br /&gt;End Try End Sub&lt;br /&gt;&lt;br /&gt;Try to know more about &lt;a href=&quot;http://msdn2.microsoft.com/en-us/library/system.timers.aspx&quot;&gt;System.Timers Namespace&lt;/a&gt;, it will here you more.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;table&gt;
&lt;tr&gt;&lt;td align=&quot;center&quot;&gt;
&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
google_ad_client = &quot;pub-8915442854222404&quot;;
google_ad_width = 250;
google_ad_height = 250;
google_ad_format = &quot;250x250_as&quot;;
google_ad_type = &quot;image&quot;;
google_ad_channel = &quot;&quot;;
//--&gt;
&lt;/script&gt;
&lt;script src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://tech-lifes.blogspot.com/feeds/8092568566523409847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/3409122642905288931/8092568566523409847' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/8092568566523409847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3409122642905288931/posts/default/8092568566523409847'/><link rel='alternate' type='text/html' href='http://tech-lifes.blogspot.com/2007/07/window-service-timer-problem-vbnet_23.html' title='Window Service timer problem - VB.NET'/><author><name>bm_boy</name><uri>http://www.blogger.com/profile/00891582537875871266</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>