<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Fransiscus Setiawan .NET Blog &#187; Javascript</title>
	<atom:link href="http://fransiscuss.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://fransiscuss.com</link>
	<description>My notepad to share knowledge with others</description>
	<pubDate>Tue, 17 Aug 2010 05:28:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Enter button in TextBox ASP.NET</title>
		<link>http://fransiscuss.com/enter-button-in-textbox-aspnet/</link>
		<comments>http://fransiscuss.com/enter-button-in-textbox-aspnet/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 05:28:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[Keypress]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=276</guid>
		<description><![CDATA[This article is demonstrating how to wire up an enter key into a textbox. For example you have a search text box where you press enter then it will click go button and at the same page you have another textbox where you want to do another button click when you press the enter which [...]]]></description>
			<content:encoded><![CDATA[<p>This article is demonstrating how to wire up an enter key into a textbox. For example you have a search text box where you press enter then it will click go button and at the same page you have another textbox where you want to do another button click when you press the enter which means it&#8217; is not necessary to post the page. This java script is used to capture the key event of enter and execute the LinkButton and ASP.NET button Click Event on the server side. Please add this javascript to your javascript common library or add this to your master page. This piece of code works in Firefox as well</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> ButtonKeyPress<span style="color: #009900;">&#40;</span>evt<span style="color: #339933;">,</span> thisElementName<span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">which</span> || evt.<span style="color: #660066;">keyCode</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">which</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">13</span><span style="color: #009900;">&#41;</span> || <span style="color: #009900;">&#40;</span>evt.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">13</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// alert('post back href: ' +document.getElementById(thisElementName).href);</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>thisElementName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                location <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>thisElementName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">href</span>;
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">else</span>
            <span style="color: #009900;">&#123;</span>
                document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>thisElementName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And add this to your .NET code behind on the page load</p>

<div class="wp_syntax"><div class="code"><pre class="vb vb" style="font-family:monospace;"> Protected <span style="color: #b1b100;">Sub</span> Page_Load<span style="color: #66cc66;">&#40;</span>ByVal sender <span style="color: #b1b100;">As</span> Object, ByVal e <span style="color: #b1b100;">As</span> System.<span style="color: #66cc66;">EventArgs</span><span style="color: #66cc66;">&#41;</span> Handles <span style="color: #b1b100;">Me</span>.<span style="color: #66cc66;">Load</span>
         <span style="color: #b1b100;">If</span> <span style="color: #b1b100;">Not</span> Page.<span style="color: #66cc66;">IsPostBack</span> <span style="color: #b1b100;">Then</span>
&nbsp;
&nbsp;
            <span style="color: #b1b100;">If</span> <span style="color: #66cc66;">&#40;</span>User.<span style="color: #66cc66;">Identity</span>.<span style="color: #66cc66;">IsAuthenticated</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">Then</span>
                Response.<span style="color: #66cc66;">Redirect</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;frmTimeMain.aspx&quot;</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span>
&nbsp;
            txtGUID.<span style="color: #66cc66;">Attributes</span>.<span style="color: #66cc66;">Add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;onkeydown&quot;</span>, <span style="color: #ff0000;">&quot;ButtonKeyPress(event, '&quot;</span> + lnkSubmit.<span style="color: #66cc66;">ClientID</span> + <span style="color: #ff0000;">&quot;')&quot;</span><span style="color: #66cc66;">&#41;</span>
            txtPassword.<span style="color: #66cc66;">Attributes</span>.<span style="color: #66cc66;">Add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;onkeydown&quot;</span>, <span style="color: #ff0000;">&quot;ButtonKeyPress(event, '&quot;</span> + lnkSubmit.<span style="color: #66cc66;">ClientID</span> + <span style="color: #ff0000;">&quot;')&quot;</span><span style="color: #66cc66;">&#41;</span>
          <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span>
    <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/enter-button-in-textbox-aspnet/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ASP.NET Calendar selected day on click method</title>
		<link>http://fransiscuss.com/aspnet-calendar-selected-day-on-click-method/</link>
		<comments>http://fransiscuss.com/aspnet-calendar-selected-day-on-click-method/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 05:17:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[Calendar]]></category>

		<category><![CDATA[Calendar javascript]]></category>

		<category><![CDATA[Calendar Selected Date]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=274</guid>
		<description><![CDATA[I&#8217;ve a case where I have an ASP.NET calendar that has a page load method that automatically select a date when it&#8217;s loaded. I also have an event defined for Selected_Changed which will be triggered only when the user select any other date other than pre-selected date on the load

Private Sub ctlCalendar_SelectionChanged&#40;ByVal sender As Object, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve a case where I have an ASP.NET calendar that has a page load method that automatically select a date when it&#8217;s loaded. I also have an event defined for Selected_Changed which will be triggered only when the user select any other date other than pre-selected date on the load</p>

<div class="wp_syntax"><div class="code"><pre class="vb vb" style="font-family:monospace;"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> ctlCalendar_SelectionChanged<span style="color: #66cc66;">&#40;</span>ByVal sender <span style="color: #b1b100;">As</span> Object, ByVal e <span style="color: #b1b100;">As</span> System.<span style="color: #66cc66;">EventArgs</span><span style="color: #66cc66;">&#41;</span> Handles ctlCalendar.<span style="color: #66cc66;">SelectionChanged</span>
        <span style="color: #b1b100;">If</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">Not</span> <span style="color: #b1b100;">String</span>.<span style="color: #66cc66;">IsNullOrEmpty</span><span style="color: #66cc66;">&#40;</span>CalendarPreviousPage<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">Then</span>
            BaseCalendar.<span style="color: #66cc66;">SelectedDate</span> = ctlCalendar.<span style="color: #66cc66;">SelectedDate</span>
            Response.<span style="color: #66cc66;">Redirect</span><span style="color: #66cc66;">&#40;</span>CalendarPreviousPage<span style="color: #66cc66;">&#41;</span>
        <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span>
    <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></pre></div></div>

<p>But how do I wire up an event or when the selecteddate being clicked?You can use DayRender event and attach it to a javascript in this case I want to go back to previous page. BaseCalendar.Selected date can be any date where you want to set up/wire up the logic</p>

<div class="wp_syntax"><div class="code"><pre class="vb vb" style="font-family:monospace;"> <span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> ctlCalendar_DayRender<span style="color: #66cc66;">&#40;</span>ByVal sender <span style="color: #b1b100;">As</span> Object, ByVal e <span style="color: #b1b100;">As</span> System.<span style="color: #66cc66;">Web</span>.<span style="color: #66cc66;">UI</span>.<span style="color: #66cc66;">WebControls</span>.<span style="color: #66cc66;">DayRenderEventArgs</span><span style="color: #66cc66;">&#41;</span> Handles ctlCalendar.<span style="color: #66cc66;">DayRender</span>
        <span style="color: #b1b100;">Dim</span> d <span style="color: #b1b100;">As</span> CalendarDay
        <span style="color: #b1b100;">Dim</span> c <span style="color: #b1b100;">As</span> TableCell
        d = e.<span style="color: #b1b100;">Day</span>
        c = e.<span style="color: #66cc66;">Cell</span>
&nbsp;
        <span style="color: #b1b100;">If</span> <span style="color: #66cc66;">&#40;</span>BaseCalendar.<span style="color: #66cc66;">SelectedDate</span>.<span style="color: #66cc66;">Value</span> = d.<span style="color: #b1b100;">Date</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">Then</span>
            c.<span style="color: #66cc66;">Attributes</span>.<span style="color: #66cc66;">Add</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;OnClick&quot;</span>, <span style="color: #ff0000;">&quot;history.go(-1)&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span>
&nbsp;
    <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/aspnet-calendar-selected-day-on-click-method/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Numeric textbox with javascript and cross browser compatible</title>
		<link>http://fransiscuss.com/numeric-textbox-with-javascript-and-cross-browser-compatible/</link>
		<comments>http://fransiscuss.com/numeric-textbox-with-javascript-and-cross-browser-compatible/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 06:12:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[numeric textbox]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=254</guid>
		<description><![CDATA[I need to make a text box that does not allow the user to type any numeric key at all

        &#60;asp:TextBox ID=&#34;txtHours&#34; runat=&#34;server&#34; onkeypress=&#34;return fnNumeric_only(event);&#34; MaxLength=&#34;4&#34; CssClass=&#34;txtHours&#34;&#62;&#60;/asp:TextBox&#62;


&#160;
// function to only allow numeric key presses in a textbox
// this doesn't stop pasting of non numeric values
function fnNumeric_only&#40;e&#41; &#123;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I need to make a text box that does not allow the user to type any numeric key at all</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">        &lt;asp:TextBox ID=&quot;txtHours&quot; runat=&quot;server&quot; onkeypress=&quot;return fnNumeric_only(event);&quot; MaxLength=&quot;4&quot; CssClass=&quot;txtHours&quot;&gt;&lt;/asp:TextBox&gt;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #006600; font-style: italic;">// function to only allow numeric key presses in a textbox</span>
<span style="color: #006600; font-style: italic;">// this doesn't stop pasting of non numeric values</span>
<span style="color: #003366; font-weight: bold;">function</span> fnNumeric_only<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// deal with unicode character sets</span>
    <span style="color: #003366; font-weight: bold;">var</span> unicode <span style="color: #339933;">=</span> e.<span style="color: #660066;">charCode</span> <span style="color: #339933;">?</span> e.<span style="color: #660066;">charCode</span> <span style="color: #339933;">:</span> e.<span style="color: #660066;">keyCode</span>;
&nbsp;
    <span style="color: #006600; font-style: italic;">// if the key is backspace, tab, or numeric</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>unicode <span style="color: #339933;">==</span> <span style="color: #CC0000;">8</span> || unicode <span style="color: #339933;">==</span> <span style="color: #CC0000;">9</span> || <span style="color: #009900;">&#40;</span>unicode <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">48</span> <span style="color: #339933;">&amp;&amp;</span> unicode <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">57</span><span style="color: #009900;">&#41;</span> || <span style="color: #009900;">&#40;</span>unicode <span style="color: #339933;">==</span> <span style="color: #CC0000;">46</span> || unicode <span style="color: #339933;">==</span> <span style="color: #CC0000;">44</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// we allow the key press</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span>;
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// otherwise we don't</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>At the sametime I also need to make the counter/tally changing by the time you start typing or deleting a character from the text box. Let&#8217;s make a scenario this way e.g 3.25 is the text in your textbox and basically what we want is when the user pressing backspace and stop in &#8220;.&#8221; character, you want your function to assume it as &#8220;3&#8243; instead of &#8220;0&#8243;, you can use this function</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> parseLocalNum<span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>num.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;ve also added these two function for getting and setting value of an input (e.g textbox and label) which is cross browser compatible</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> getControlValue<span style="color: #009900;">&#40;</span>controlName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> controlValue <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>;
    <span style="color: #003366; font-weight: bold;">var</span> hasInnerText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">!=</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>;
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>hasInnerText<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        controlValue <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>controlName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span>;
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        controlValue <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>controlName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">textContent</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> controlValue;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> setControlValue<span style="color: #009900;">&#40;</span>controlName<span style="color: #339933;">,</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> controlValue <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>;
    <span style="color: #003366; font-weight: bold;">var</span> hasInnerText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span>0<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">!=</span> undefined<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>;
&nbsp;
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>hasInnerText<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>controlName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerText</span> <span style="color: #339933;">=</span> value;
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>controlName<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">textContent</span> <span style="color: #339933;">=</span> value;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> controlValue;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>How to use getControlValue or setControlValue</p>

<div class="wp_syntax"><div class="code"><pre class="javascript javascript" style="font-family:monospace;">    setControlValue<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ctl00_ContentPlaceHolder1_lblClaimedHours&quot;</span><span style="color: #339933;">,</span> totalClaimed.<span style="color: #660066;">toFixed</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLocaleString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/numeric-textbox-with-javascript-and-cross-browser-compatible/feed/</wfw:commentRss>
		</item>
		<item>
		<title>an activex control on this page might be unsafe to interact with other parts of the page. do you want to allow this interaction?</title>
		<link>http://fransiscuss.com/an-activex-control-on-this-page-might-be-unsafe-to-interact-with-other-parts-of-the-page-do-you-want-to-allow-this-interaction/</link>
		<comments>http://fransiscuss.com/an-activex-control-on-this-page-might-be-unsafe-to-interact-with-other-parts-of-the-page-do-you-want-to-allow-this-interaction/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 06:18:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[C#]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=233</guid>
		<description><![CDATA[I keep getting this message &#8220;an activex control on this page might be unsafe to interact with other parts of the page. do you want to allow this interaction&#8221; when I try to access a page that use Javascript to access ActiveX Code. I&#8217;ve spent quite sometime to get rid of this error message and [...]]]></description>
			<content:encoded><![CDATA[<p>I keep getting this message &#8220;an activex control on this page might be unsafe to interact with other parts of the page. do you want to allow this interaction&#8221; when I try to access a page that use Javascript to access ActiveX Code. I&#8217;ve spent quite sometime to get rid of this error message and I found out that</p>
<ol>
<li>The code need implement IObjectSafety Interface</li>
<li>You need to digitally sign the code with valid certificate</li>
</ol>
<p><strong>Step 1 :</strong> Detail on how to implement IObjectSafety<br />
-Create an interface file called as IObjectSafety.vb/IObjectSafety.cs</p>
<p>CSharp (IObjectSafety.cs) :</p>

<div class="wp_syntax"><div class="code"><pre class="csharp csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>ComImport<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span>Guid<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;CB5BDC81-93C1-11CF-8F20-00805F2CD064&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #000000;">&#91;</span>InterfaceType<span style="color: #000000;">&#40;</span>ComInterfaceType.<span style="color: #0000FF;">InterfaceIsIUnknown</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
<span style="color: #FF0000;">interface</span> IObjectSafety <span style="color: #000000;">&#123;</span>
   <span style="color: #000000;">&#91;</span>PreserveSig<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
   <span style="color: #FF0000;">int</span> GetInterfaceSafetyOptions<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> Guid riid, <span style="color: #0600FF;">out</span> <span style="color: #FF0000;">int</span> pdwSupportedOptions, <span style="color: #0600FF;">out</span> <span style="color: #FF0000;">int</span> pdwEnabledOptions<span style="color: #000000;">&#41;</span>;
&nbsp;
   <span style="color: #000000;">&#91;</span>PreserveSig<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
   <span style="color: #FF0000;">int</span> SetInterfaceSafetyOptions<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> Guid riid, <span style="color: #FF0000;">int</span> dwOptionSetMask, <span style="color: #FF0000;">int</span> dwEnabledOptions<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="vb vb" style="font-family:monospace;">Imports System.<span style="color: #66cc66;">Runtime</span>.<span style="color: #66cc66;">InteropServices</span>
&nbsp;
&lt;ComImport<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>&gt; _
&lt;Guid<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;CB5BDC81-93C1-11CF-8F20-00805F2CD064&quot;</span><span style="color: #66cc66;">&#41;</span>&gt; _
&lt;InterfaceType<span style="color: #66cc66;">&#40;</span>ComInterfaceType.<span style="color: #66cc66;">InterfaceIsIUnknown</span><span style="color: #66cc66;">&#41;</span>&gt; _
Interface IObjectSafety
    &lt;PreserveSig<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>&gt; _
    <span style="color: #b1b100;">Function</span> GetInterfaceSafetyOptions<span style="color: #66cc66;">&#40;</span>ByRef riid <span style="color: #b1b100;">As</span> Guid, ByRef pdwSupportedOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>, ByRef pdwEnabledOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>
&nbsp;
    &lt;PreserveSig<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>&gt; _
    <span style="color: #b1b100;">Function</span> SetInterfaceSafetyOptions<span style="color: #66cc66;">&#40;</span>ByRef riid <span style="color: #b1b100;">As</span> Guid, ByVal dwOptionSetMask <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>, ByVal dwEnabledOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>
<span style="color: #b1b100;">End</span> Interface</pre></div></div>

<p>in your ActiveX code you need to implement IObjectSafety</p>
<p>CSharp:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp csharp" style="font-family:monospace;">&nbsp;</pre></div></div>

<p>VB.NET:</p>

<div class="wp_syntax"><div class="code"><pre class="vb vb" style="font-family:monospace;">&lt;ProgId<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Fransiscus.Authentication.ClientUtility&quot;</span><span style="color: #66cc66;">&#41;</span>&gt; _
&lt;ClassInterface<span style="color: #66cc66;">&#40;</span>ClassInterfaceType.<span style="color: #66cc66;">AutoDual</span><span style="color: #66cc66;">&#41;</span>, ComSourceInterfaces<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;ControlEvents&quot;</span><span style="color: #66cc66;">&#41;</span>&gt; _
&lt;Guid<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;0577147B-6941-4f15-9EFB-2551FEB3D6CC&quot;</span><span style="color: #66cc66;">&#41;</span>&gt; _
&lt;ComVisible<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">True</span><span style="color: #66cc66;">&#41;</span>&gt; _
<span style="color: #b1b100;">Public</span> NotInheritable Class ClientUtility
    <span style="color: #b1b100;">Implements</span> IObjectSafety
&nbsp;
&nbsp;
#Region <span style="color: #ff0000;">&quot;IObjectSafety Constants&quot;</span>
&nbsp;
    <span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Const</span> INTERFACESAFE_FOR_UNTRUSTED_CALLER <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> = &amp;H1
    <span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Const</span> INTERFACESAFE_FOR_UNTRUSTED_DATA <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> = &amp;H2
    <span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Const</span> S_OK <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> = 0
&nbsp;
#End Region
&nbsp;
#Region <span style="color: #ff0000;">&quot;IObjectSafety Methods&quot;</span>
&nbsp;
    <span style="color: #b1b100;">Public</span> <span style="color: #b1b100;">Function</span> GetInterfaceSafetyOptions<span style="color: #66cc66;">&#40;</span>ByRef riid <span style="color: #b1b100;">As</span> System.<span style="color: #66cc66;">Guid</span>, ByRef pdwSupportedOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>, ByRef pdwEnabledOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> <span style="color: #b1b100;">Implements</span> IObjectSafety.<span style="color: #66cc66;">GetInterfaceSafetyOptions</span>
        pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER <span style="color: #b1b100;">Or</span> INTERFACESAFE_FOR_UNTRUSTED_DATA
        pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER <span style="color: #b1b100;">Or</span> INTERFACESAFE_FOR_UNTRUSTED_DATA
        <span style="color: #b1b100;">Return</span> S_OK
    <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Function</span>
&nbsp;
    <span style="color: #b1b100;">Public</span> <span style="color: #b1b100;">Function</span> SetInterfaceSafetyOptions<span style="color: #66cc66;">&#40;</span>ByRef riid <span style="color: #b1b100;">As</span> System.<span style="color: #66cc66;">Guid</span>, ByVal dwOptionSetMask <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span>, ByVal dwEnabledOptions <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> <span style="color: #b1b100;">Implements</span> IObjectSafety.<span style="color: #66cc66;">SetInterfaceSafetyOptions</span>
        <span style="color: #b1b100;">Return</span> S_OK
    <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Function</span>
&nbsp;
#End Region</pre></div></div>

<p>CSharp:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>ProgId<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Fransiscus.Authentication.ClientUtility&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> 
<span style="color: #000000;">&#91;</span>ClassInterface<span style="color: #000000;">&#40;</span>ClassInterfaceType.<span style="color: #0000FF;">AutoDual</span><span style="color: #000000;">&#41;</span>, ComSourceInterfaces<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;ControlEvents&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> 
<span style="color: #000000;">&#91;</span>Guid<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;0577147B-6941-4f15-9EFB-2551FEB3D6CC&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> 
<span style="color: #000000;">&#91;</span>ComVisible<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span> 
<span style="color: #0600FF;">public</span> <span style="color: #0600FF;">sealed</span> <span style="color: #FF0000;">class</span> ClientUtility <span style="color: #008000;">:</span> IObjectSafety 
<span style="color: #000000;">&#123;</span> 
&nbsp;
&nbsp;
    <span style="color: #008080;">#region &quot;IObjectSafety Constants&quot; </span>
&nbsp;
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">int</span> INTERFACESAFE_FOR_UNTRUSTED_CALLER <span style="color: #008000;">=</span> 0x1; 
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">int</span> INTERFACESAFE_FOR_UNTRUSTED_DATA <span style="color: #008000;">=</span> 0x2; 
    <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">int</span> S_OK <span style="color: #008000;">=</span> 0; 
&nbsp;
    <span style="color: #008080;">#endregion </span>
&nbsp;
    <span style="color: #008080;">#region &quot;IObjectSafety Methods&quot; </span>
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> GetInterfaceSafetyOptions<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Guid</span> riid, <span style="color: #0600FF;">ref</span> <span style="color: #FF0000;">int</span> pdwSupportedOptions, <span style="color: #0600FF;">ref</span> <span style="color: #FF0000;">int</span> pdwEnabledOptions<span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#123;</span> 
        pdwSupportedOptions <span style="color: #008000;">=</span> INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA; 
        pdwEnabledOptions <span style="color: #008000;">=</span> INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA; 
        <span style="color: #0600FF;">return</span> S_OK; 
    <span style="color: #000000;">&#125;</span> 
&nbsp;
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> SetInterfaceSafetyOptions<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">ref</span> <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Guid</span> riid, <span style="color: #FF0000;">int</span> dwOptionSetMask, <span style="color: #FF0000;">int</span> dwEnabledOptions<span style="color: #000000;">&#41;</span> 
    <span style="color: #000000;">&#123;</span> 
        <span style="color: #0600FF;">return</span> S_OK; 
    <span style="color: #000000;">&#125;</span> 
<span style="color: #008080;">#endregion</span>
&nbsp;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><Strong>Step 2:</strong><br />
You need to obtain certificate and sign it, You also need Windows Server 2008 SDK to sign your code using SignTool.exe (type Signtool SignWizard in command prompt to follow the wizard and sign your DLL)<br />For more detail please open verisign website (http://www.verisign.com/support/code-signing-support/code-signing/identity-authentication.html) or click <a href="http://www.verisign.com/support/code-signing-support/code-signing/identity-authentication.html" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/an-activex-control-on-this-page-might-be-unsafe-to-interact-with-other-parts-of-the-page-do-you-want-to-allow-this-interaction/feed/</wfw:commentRss>
		</item>
		<item>
		<title>key event handler that compatible with all browsers using javascript</title>
		<link>http://fransiscuss.com/key-event-handler-that-compatible-with-all-browsers-using-javascript/</link>
		<comments>http://fransiscuss.com/key-event-handler-that-compatible-with-all-browsers-using-javascript/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 22:41:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=121</guid>
		<description><![CDATA[This might be useful for web developer which wants to have one key event handler that compatible with all browsers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
&#60;script language=JavaScript&#62;
document.onkeyup = KeyCheck;      
&#160;
function KeyCheck&#40;e&#41;
&#123;
  //this is used for cross browser
  var KeyID = &#40;window.event&#41; ? event.keyCode : e.keyCode;
&#160;
  switch&#40;KeyID&#41;
   &#123;
&#160;
   case 13:
 [...]]]></description>
			<content:encoded><![CDATA[<p>This might be useful for web developer which wants to have one key event handler that compatible with all browsers.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script language<span style="color: #339933;">=</span>JavaScript<span style="color: #339933;">&gt;</span>
document.<span style="color: #660066;">onkeyup</span> <span style="color: #339933;">=</span> KeyCheck;      
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> KeyCheck<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">//this is used for cross browser</span>
  <span style="color: #003366; font-weight: bold;">var</span> KeyID <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">event</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> event.<span style="color: #660066;">keyCode</span> <span style="color: #339933;">:</span> e.<span style="color: #660066;">keyCode</span>;
&nbsp;
  <span style="color: #000066; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>KeyID<span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">13</span><span style="color: #339933;">:</span>
    checkPostCodeSelection<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #000066; font-weight: bold;">break</span>;      
      <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/key-event-handler-that-compatible-with-all-browsers-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AJAX Update Panel Timeout Issue</title>
		<link>http://fransiscuss.com/ajax-update-panel-timeout-issue/</link>
		<comments>http://fransiscuss.com/ajax-update-panel-timeout-issue/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 07:24:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=98</guid>
		<description><![CDATA[I have an asp.net page where the page will query the report from the database. To query the report itself might cause timeout exception on the page itself before the report result is being returned from database. 
You need to do it in two steps, first you need to override the script timeout only for [...]]]></description>
			<content:encoded><![CDATA[<p>I have an asp.net page where the page will query the report from the database. To query the report itself might cause timeout exception on the page itself before the report result is being returned from database. </p>
<p>You need to do it in two steps, first you need to override the script timeout only for the pageitself. put this code in your code behind</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="vbnet vbnet" style="font-family:monospace;">    <span style="color: #0600FF;">Dim</span> pageTimeOut <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Integer</span>     
Protected <span style="color: #0600FF;">Sub</span> Page_Init<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Init</span>  
        pageTimeOut <span style="color: #008000;">=</span> Server.<span style="color: #0000FF;">ScriptTimeout</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">'this is in seconds</span>
        Server.<span style="color: #0000FF;">ScriptTimeout</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">2500</span>     
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>     
&nbsp;
Protected <span style="color: #0600FF;">Sub</span> Page_Unload<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Unload</span>        
&nbsp;
Server.<span style="color: #0000FF;">ScriptTimeout</span> <span style="color: #008000;">=</span> pageTimeOut 
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

<p>The next step is required only if you use AJAX Update panel. Put this script on the aspx page</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>     
   Sys.<span style="color: #660066;">WebForms</span>.<span style="color: #660066;">PageRequestManager</span>.<span style="color: #660066;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">add_endRequest</span><span style="color: #009900;">&#40;</span>
        <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>sender<span style="color: #339933;">,</span> args<span style="color: #009900;">&#41;</span> 
        <span style="color: #009900;">&#123;</span>         
             <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>args.<span style="color: #660066;">get_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> args.<span style="color: #660066;">get_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Sys.WebForms.PageRequestManagerTimeoutException'</span><span style="color: #009900;">&#41;</span> 
            <span style="color: #009900;">&#123;</span>            
                  <span style="color: #006600; font-style: italic;">// remember to set errorHandled = true to keep from getting a popup from the AJAX library itself            </span>
                 args.<span style="color: #660066;">set_errorHandled</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>;         
             <span style="color: #009900;">&#125;</span>     
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>; 
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/ajax-update-panel-timeout-issue/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Set Default value with clear text for input type=&#8221;password&#8221;</title>
		<link>http://fransiscuss.com/set-default-value-with-clear-text-for-input-typepassword/</link>
		<comments>http://fransiscuss.com/set-default-value-with-clear-text-for-input-typepassword/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 06:18:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[VB.NET]]></category>

		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=84</guid>
		<description><![CDATA[Normally we have two text boxes which is user name and password. On the first load of the page we want to set the default value of user name text box becoming &#8216;username&#8217; and set the default value of password text box becoming &#8216;password&#8217; not &#8216;*******&#8217;. 
Well what most of us think that we can [...]]]></description>
			<content:encoded><![CDATA[<p>Normally we have two text boxes which is user name and password. On the first load of the page we want to set the default value of user name text box becoming &#8216;username&#8217; and set the default value of password text box becoming &#8216;password&#8217; not &#8216;*******&#8217;. </p>
<p>Well what most of us think that we can use javascript to change the type of the input box?well I&#8217;ve got this trick to have two textboxes in the same location and swap it with &#8220;OnFocus&#8221; event</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">  &lt;span id=&quot;fakePassDiv&quot; style=&quot;display: block;&quot;&gt;
            &lt;input name=&quot;txtFakePassword&quot; type=&quot;text&quot; class=&quot;text&quot; maxlength=&quot;255&quot; style=&quot;position:absolute;top:0px; right: 20px; width: 120px;&quot; value=&quot;password&quot;
                onfocus=&quot;javascript:document.getElementById('realPassDiv').style.display='inline';document.getElementById('fakePassDiv').style.display='none';document.getElementById('ctl00_ucLoginControl_txtPassword').focus();&quot;
                tabindex=&quot;2&quot; /&gt;&lt;/span&gt; 
&nbsp;
    &lt;span id=&quot;realPassDiv&quot; style=&quot;display: none;&quot;&gt;
        &lt;asp:TextBox ID=&quot;txtPassword&quot; TextMode=&quot;password&quot; runat=&quot;server&quot; style=&quot;position:absolute;top:0px; right: 20px; width: 120px;&quot; /&gt;
    &lt;/span&gt;</pre></td></tr></table></div>

<p><strong>Set the default value for username text box via code behind</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="vbnet vbnet" style="font-family:monospace;">      Protected <span style="color: #0600FF;">Sub</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Load</span>
            txtUserName.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;onfocus&quot;</span>, <span style="color: #808080;">&quot;JavaScript:if(this.value=='username'){this.value=''};&quot;</span><span style="color: #000000;">&#41;</span>
            txtUserName.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;onblur&quot;</span>, <span style="color: #808080;">&quot;JavaScript:if(this.value==''){this.value='username'};&quot;</span><span style="color: #000000;">&#41;</span>
            txtUserName.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;value&quot;</span>, <span style="color: #808080;">&quot;username&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
            txtPassword.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;onkeydown&quot;</span>, _
                                            <span style="color: #808080;">&quot;javascript:if((event.which &amp;&amp; event.which == 13) || &quot;</span> _
                                            <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;(event.keyCode &amp;&amp; event.keyCode == 13))&quot;</span> _
                                            <span style="color: #008000;">+</span> <span style="color: #808080;">&quot; {document.getElementById('&quot;</span> <span style="color: #008000;">+</span> btnLogin.<span style="color: #0000FF;">ClientID</span> <span style="color: #008000;">+</span> <span style="color: #808080;">&quot;').click(); &quot;</span> _
                                            <span style="color: #008000;">+</span> <span style="color: #808080;">&quot; return false; } else return true;&quot;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/set-default-value-with-clear-text-for-input-typepassword/feed/</wfw:commentRss>
		</item>
		<item>
		<title>XML http object cross browser</title>
		<link>http://fransiscuss.com/xml-http-object-cross-browser/</link>
		<comments>http://fransiscuss.com/xml-http-object-cross-browser/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 05:18:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[ASP.NET]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=65</guid>
		<description><![CDATA[I believe this will be useful for everyone who wants to implement AJAX manually and make it compatible cross browser.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
&#60;script type=&#34;text/javascript&#34;&#62; 
&#160;
           // cross-browser method to retrieve an XMLHttp object for asynchronous requests &#38; responses
           [...]]]></description>
			<content:encoded><![CDATA[<p>I believe this will be useful for everyone who wants to implement AJAX manually and make it compatible cross browser.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span> 
&nbsp;
           <span style="color: #006600; font-style: italic;">// cross-browser method to retrieve an XMLHttp object for asynchronous requests &amp; responses</span>
            <span style="color: #003366; font-weight: bold;">function</span> GetHTTPRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> http_request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span>;
&nbsp;
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span> 
                <span style="color: #009900;">&#123;</span> 
                    <span style="color: #006600; font-style: italic;">// Mozilla, Safari,...</span>
                    http_request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>http_request.<span style="color: #660066;">overrideMimeType</span><span style="color: #009900;">&#41;</span> 
                    <span style="color: #009900;">&#123;</span>
                        http_request.<span style="color: #660066;">overrideMimeType</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;text/xml&quot;</span><span style="color: #009900;">&#41;</span>;
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span> 
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> 
                <span style="color: #009900;">&#123;</span> 
                    <span style="color: #006600; font-style: italic;">// IE</span>
                    <span style="color: #000066; font-weight: bold;">try</span> 
                    <span style="color: #009900;">&#123;</span>
                        http_request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Msxml2.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span>;
                    <span style="color: #009900;">&#125;</span> 
                    <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> 
                    <span style="color: #009900;">&#123;</span>
                        <span style="color: #000066; font-weight: bold;">try</span> 
                        <span style="color: #009900;">&#123;</span>
                            http_request <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Microsoft.XMLHTTP&quot;</span><span style="color: #009900;">&#41;</span>;
                        <span style="color: #009900;">&#125;</span> 
                        <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">return</span> http_request;
            <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/xml-http-object-cross-browser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Querystring in Javascript</title>
		<link>http://fransiscuss.com/querystring-in-javascript/</link>
		<comments>http://fransiscuss.com/querystring-in-javascript/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 21:29:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[querystring]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=16</guid>
		<description><![CDATA[This is a function to capture querystring in javascript. I used this javascript to control my menu dynamically.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
&#60;script type=&#34;text/javascript&#34;&#62;
function getQueryString&#40;strParamName&#41;&#123;
var strReturn = &#34;&#34;;
var strHref = window.location.href;
if &#40; strHref.indexOf&#40;&#34;?&#34;&#41; &#62; -1 &#41;&#123;
var strQueryString = strHref.substr&#40;strHref.indexOf&#40;&#34;?&#34;&#41;&#41;.toLowerCase&#40;&#41;;
var aQueryString = strQueryString.split&#40;&#34;&#38;&#34;&#41;;
for &#40; var iParam = 0; iParam &#38;lt; aQueryString.length; iParam++ &#41;&#123;
if &#40;
aQueryString&#91;iParam&#93;.indexOf&#40;strParamName.toLowerCase&#40;&#41; + &#34;=&#34;&#41; &#62; -1 &#41;&#123;
var aParam = [...]]]></description>
			<content:encoded><![CDATA[<p>This is a function to capture querystring in javascript. I used this javascript to control my menu dynamically.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> getQueryString<span style="color: #009900;">&#40;</span>strParamName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> strReturn <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span>;
<span style="color: #003366; font-weight: bold;">var</span> strHref <span style="color: #339933;">=</span> window.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span>;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> strHref.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> strQueryString <span style="color: #339933;">=</span> strHref.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span>strHref.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #003366; font-weight: bold;">var</span> aQueryString <span style="color: #339933;">=</span> strQueryString.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&amp;&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> iParam <span style="color: #339933;">=</span> 0; iParam <span style="color: #339933;">&amp;</span>lt; aQueryString.<span style="color: #660066;">length</span>; iParam<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>
aQueryString<span style="color: #009900;">&#91;</span>iParam<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>strParamName.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> aParam <span style="color: #339933;">=</span> aQueryString<span style="color: #009900;">&#91;</span>iParam<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #009900;">&#41;</span>;
strReturn <span style="color: #339933;">=</span> aParam<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>;
<span style="color: #000066; font-weight: bold;">break</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">return</span> unescape<span style="color: #009900;">&#40;</span>strReturn<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/querystring-in-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Register Javascript to hide Div</title>
		<link>http://fransiscuss.com/register-javascript-to-hide-div/</link>
		<comments>http://fransiscuss.com/register-javascript-to-hide-div/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 21:10:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[startup script]]></category>

		<guid isPermaLink="false">http://fransiscuss.com/?p=11</guid>
		<description><![CDATA[Sometimes people add javascript into the aspx page instead of using code behind but there is a case when we need to add javascript in the runtime using code behind. This is the example where javascript is used to provide switching of visibility based on the table visibility status. I used this technique to hide [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes people add javascript into the aspx page instead of using code behind but there is a case when we need to add javascript in the runtime using code behind. This is the example where javascript is used to provide switching of visibility based on the table visibility status. I used this technique to hide another user control when user click expand button. Client ID is required to know the real ID of the user control after rendering. In here we also add onclick event to the image tag.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="csharp csharp" style="font-family:monospace;"><span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #008000;">!</span><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Page</span>.<span style="color: #0000FF;">IsStartupScriptRegistered</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;tableScript&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #FF0000;">string</span> script <span style="color: #008000;">=</span> <span style="">@&quot;&lt;script language='javascript'&gt;function checkVisibility() &quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;{&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;    var element = document.getElementById('&quot;</span> <span style="color: #008000;">+</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">OuterTableDetailSearch</span>.<span style="color: #0000FF;">ClientID</span> <span style="color: #008000;">+</span> <span style="">@&quot;');&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;    var elementBtn = document.getElementById('&quot;</span> <span style="color: #008000;">+</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">btnExp</span>.<span style="color: #0000FF;">ClientID</span> <span style="color: #008000;">+</span> <span style="">@&quot;');&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;    if (element.style['visibility'] == 'hidden')&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;{&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;element.style['visibility'] = 'visible';&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;elementBtn.src = '/Images/button_expand.gif';&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;}&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;else&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;{&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;element.style['visibility'] = 'hidden';&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;elementBtn.src = '/Images/image_casestudy_search.gif';&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;}&quot;</span>
<span style="color: #008000;">+</span> <span style="">@&quot;}&lt;/script&gt;&quot;</span>;
&nbsp;
<span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">Page</span>.<span style="color: #0000FF;">RegisterStartupScript</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;tableScript&quot;</span>, script<span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
btnExp.<span style="color: #0000FF;">Attributes</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;OnClick&quot;</span>,
               <span style="color: #666666;">&quot;javascript:checkVisibility()&quot;</span><span style="color: #000000;">&#41;</span>;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://fransiscuss.com/register-javascript-to-hide-div/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
