<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Thomas&#8217; Developer Blog</title>
	<atom:link href="https://sanzon.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://sanzon.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 31 Jan 2012 06:23:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='sanzon.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s0.wp.com/i/buttonw-com.png</url>
		<title>Thomas&#8217; Developer Blog</title>
		<link>https://sanzon.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://sanzon.wordpress.com/osd.xml" title="Thomas&#039; Developer Blog" />
	<atom:link rel='hub' href='https://sanzon.wordpress.com/?pushpress=hub'/>
	<item>
		<title>Filtering many to many queries in mySQL using &#8220;having.&#8221;</title>
		<link>https://sanzon.wordpress.com/2012/01/31/filtering-many-to-many-queries-in-mysql-using-having/</link>
					<comments>https://sanzon.wordpress.com/2012/01/31/filtering-many-to-many-queries-in-mysql-using-having/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Tue, 31 Jan 2012 06:21:41 +0000</pubDate>
				<category><![CDATA[sql]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=119</guid>

					<description><![CDATA[I rarely update this blog anymore except when I run into something that really bugs me. I started with 3 tables. Product_ID Name 1 Orange 2 Apple 3 Banana Category_ID Name 1 Red 2 Orange 3 Round 4 Long Product_ID Category_ID 1 1 1 3 2 2 3 4 &#160; &#160; &#160; &#160; The problem [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I rarely update this blog anymore except when I run into something that really bugs me. I started with 3 tables.</p>
<table style="float:left;margin-right:10px;" border="1">
<tbody>
<tr>
<td>Product_ID</td>
<td>Name</td>
</tr>
<tr>
<td>1</td>
<td>Orange</td>
</tr>
<tr>
<td>2</td>
<td>Apple</td>
</tr>
<tr>
<td>3</td>
<td>Banana</td>
</tr>
</tbody>
</table>
<table style="float:left;margin-right:10px;" border="1">
<tbody>
<tr>
<td>Category_ID</td>
<td>Name</td>
</tr>
<tr>
<td>1</td>
<td>Red</td>
</tr>
<tr>
<td>2</td>
<td>Orange</td>
</tr>
<tr>
<td>3</td>
<td>Round</td>
</tr>
<tr>
<td>4</td>
<td>Long</td>
</tr>
</tbody>
</table>
<table style="float:left;margin-right:10px;" border="1">
<tbody>
<tr>
<td>Product_ID</td>
<td>Category_ID</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The problem is I wanted to select only products that were round and red. However, the problem is you can&#8217;t use a where statement like:</p>
<p><em>&#8220;select distinct product_id from product join product_to_category using(product_id)  where category_id = 1 and category_id = 3&#8221;</em></p>
<p>This would return 0 results.</p>
<p>The best way to do this is to use a Group By Product_ID along with a Having clause as such:</p>
<p><em>&#8220;select distinct product_id from product join product_to_category using(product_id)  group by product_id having sum(if(category_id in (1,3),1,0)) = 2&#8221;</em></p>
<p>This will return only products that are both red and round.</p>
<p><strong>How does the having clause work?</strong></p>
<p>Having is similar to where except for it takes place <em>after </em>all rows have been collected. Generally it filters the results. Now let&#8217;s look at the statement:</p>
<p><em>&#8220;having sum(if(category_id in (1,3),1,0)) = 2&#8221;</em></p>
<p>What this code does is pretty simple. It checks each category_id in product_to_category for a match. If there is a match a 1 is returned, if no matches it returns a 0. Because they are grouped we add up the number of matches. In this case there are 2 categories we are looking for so this value must &#8220;= 2&#8221;.</p>
<p>That&#8217;s it! Fast and clean!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2012/01/31/filtering-many-to-many-queries-in-mysql-using-having/feed/</wfw:commentRss>
			<slash:comments>24</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Checking if executescalar returns a result in VB.Net</title>
		<link>https://sanzon.wordpress.com/2011/05/29/checking-if-executescalar-returns-a-result-in-vb-net/</link>
					<comments>https://sanzon.wordpress.com/2011/05/29/checking-if-executescalar-returns-a-result-in-vb-net/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Sun, 29 May 2011 18:01:33 +0000</pubDate>
				<category><![CDATA[.Net Framework 3.5]]></category>
		<category><![CDATA[Asp.Net Framework 2.0]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[vb.net]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=115</guid>

					<description><![CDATA[Yea, it&#8217;s been over a year since I updated this blog, but spending 15-20 minutes finding a solution to something so simple got a bit annoying so here&#8217;s the solution for future searchers! If you run executescalar it returns the first column/result. The problem is if you don&#8217;t have a result it returns nothing. Keyword: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Yea, it&#8217;s been over a year since I updated this blog, but spending 15-20 minutes finding a solution to something so simple got a bit annoying so here&#8217;s the solution for future searchers!</p>
<p>If you run executescalar it returns the first column/result. The problem is if you don&#8217;t have a result it returns <span style="text-decoration:underline;">nothing</span>.</p>
<p>Keyword: nothing</p>
<p>Yes you&#8217;re working with a database so you would assume it&#8217;s DBNull, but if there is an empty table SQL is not going to return DBNull, but will return nothing.</p>
<p>Solution:</p>
<p>Dim sqlResult as object = sqlCMD.executescalar()</p>
<p>if sqlResult is nothing then<br />
&#8216; No result found<br />
else<br />
sqlResult.tostring   &#8216;result found<br />
end if</p>
<p>Simple!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2011/05/29/checking-if-executescalar-returns-a-result-in-vb-net/feed/</wfw:commentRss>
			<slash:comments>62</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Whitelist HTML Tags (Advance Methods for Prevention against Javascript Injections)</title>
		<link>https://sanzon.wordpress.com/2010/01/17/whitelist-html-tags-advance-methods-for-prevention-against-javascript-injections/</link>
					<comments>https://sanzon.wordpress.com/2010/01/17/whitelist-html-tags-advance-methods-for-prevention-against-javascript-injections/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Sun, 17 Jan 2010 04:42:52 +0000</pubDate>
				<category><![CDATA[.Net Framework 3.5]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[control]]></category>
		<category><![CDATA[htmleditor]]></category>
		<category><![CDATA[htmlencode]]></category>
		<category><![CDATA[injection]]></category>
		<category><![CDATA[toolkit]]></category>
		<category><![CDATA[whitelist]]></category>
		<category><![CDATA[xss attacks]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=106</guid>

					<description><![CDATA[NOTE: This method is no longer preferred. Please see Microsoft Anti-Cross Site Scripting Library V4.2 http://www.microsoft.com/download/en/details.aspx?id=28589  Long time no update! I&#8217;m shocked to see I&#8217;m still getting over 100 posts a day considering I haven&#8217;t updated in months. Well I wrote a little script to help everyone out who is using the HTMLeditor that ships with [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>NOTE: This method is no longer preferred. Please see Microsoft Anti-Cross Site Scripting Library V4.2<br />
<a href="http://www.microsoft.com/download/en/details.aspx?id=28589">http://www.microsoft.com/download/en/details.aspx?id=28589</a> </strong></p>
<p>Long time no update! I&#8217;m shocked to see I&#8217;m still getting over 100 posts a day considering I haven&#8217;t updated in months.</p>
<p>Well I wrote a little script to help everyone out who is using the HTMLeditor that ships with asp.net&#8217;s AJAX Control Toolkit. Hope you enjoy!</p>
<div style="background-color:#cccccc;">
<pre>Function HTMLStream(ByVal InputValue As String, Optional ByVal WhiteList As String = "p|span|ol|li|ul|hr|div|i|b|h1|h2|h3|h4|a|br|img|font") As String</pre>
<pre style="padding-left:30px;">Dim ReturnValue As String</pre>
<pre style="padding-left:30px;">ReturnValue = Regex.Replace(InputValue, "&lt;(?!(" &amp; WhiteList &amp; ")\b)[^&gt;]+&gt;([^.]|[.])*(&lt;(?!/?(" &amp; WhiteList &amp; ")\b)[^&gt;]+&gt;)", "", RegexOptions.IgnoreCase)</pre>
<pre style="padding-left:30px;">While (Regex.IsMatch(ReturnValue, "(&lt;[\s\S]*?) on.*?\=(['""])[\s\S]*?\2([\s\S]*?&gt;)", RegexOptions.Compiled Or RegexOptions.IgnoreCase))</pre>
<pre style="padding-left:60px;">ReturnValue = Regex.Replace(ReturnValue, "(&lt;[\s\S]*?) on.*?\=(['""])[\s\S]*?\2([\s\S]*?&gt;)", _</pre>
<pre style="padding-left:60px;">Function(match As Match) [String].Concat(match.Groups(1).Value, match.Groups(3).Value), RegexOptions.Compiled Or RegexOptions.IgnoreCase)</pre>
<pre style="padding-left:30px;">End While</pre>
<pre style="padding-left:30px;">ReturnValue = Regex.Replace(ReturnValue, "(?&lt;=&lt;.*)href=""(?!http://|www\.)[^""]*""", "", RegexOptions.IgnoreCase)</pre>
<pre style="padding-left:30px;">Return ReturnValue
End Function</pre>
</div>
<p>Now if you want to know how this script works you can continue reading. As a warning I will be assuming that you know regex and intermediate VB.Net code (If you want C# there are a lot of conversion applications online.)</p>
<p><strong>Part 1</strong><br />
The function starts off with two variables. InputValue, which is self described, and the optional WhiteList. WhiteList is a list of HTML characters which will be accepted. By default it&#8217;s pretty generous.</p>
<p><strong>Part 2<br />
<span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-weight:normal;line-height:18px;font-size:12px;white-space:pre;">ReturnValue = Regex.Replace(InputValue, &#8220;&lt;(?!(&#8221; &amp; WhiteList &amp; &#8220;)\b)[^&gt;]+&gt;([^.]|[.])*(&lt;(?!/?(&#8221; &amp; WhiteList &amp; &#8220;)\b)[^&gt;]+&gt;)&#8221;, &#8220;&#8221;, RegexOptions.IgnoreCase)</span></strong></p>
<p>This line searches every HTML tag and checks to see if it matches any of the values in the WhiteList group. If it doesn&#8217;t it clears out the tag and <span style="text-decoration:underline;">ALL </span>of it&#8217;s contents. This is setup to be greedy! Why greedy? Because it&#8217;s for security! I don&#8217;t want to remove just the tag, I want to remove <span style="text-decoration:underline;">EVERYTHING </span>inside of the tag. So be <span style="text-decoration:underline;">WARNED</span>, altering the WhiteList tags may result in lost of user input.</p>
<p><strong>Part 3<br />
</strong></p>
<pre style="padding-left:30px;">While (Regex.IsMatch(ReturnValue, "(&lt;[\s\S]*?) on.*?\=(['""])[\s\S]*?\2([\s\S]*?&gt;)", RegexOptions.Compiled Or RegexOptions.IgnoreCase))</pre>
<pre style="padding-left:60px;">ReturnValue = Regex.Replace(ReturnValue, "(&lt;[\s\S]*?) on.*?\=(['""])[\s\S]*?\2([\s\S]*?&gt;)", _</pre>
<pre style="padding-left:60px;">Function(match As Match) [String].Concat(match.Groups(1).Value, match.Groups(3).Value), RegexOptions.Compiled Or RegexOptions.IgnoreCase)</pre>
<pre style="padding-left:30px;">End While</pre>
<p>This next part is a bit confusing. Generally this goes the extra step most scripts don&#8217;t bother to do. Which is a shame since it fails to remove those pesky JavaScript event handlers.</p>
<p><strong>Part 4<br />
<span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;font-weight:normal;line-height:18px;font-size:12px;white-space:pre;">ReturnValue = Regex.Replace(ReturnValue, &#8220;(?&lt;=&lt;.*)href=&#8221;&#8221;(?!<a href="http://">http://</a>|www\.)[^&#8221;&#8221;]*&#8221;&#8221;&#8221;, &#8220;&#8221;, RegexOptions.IgnoreCase)</span></strong></p>
<p>The final part is to go through and remove all javascript injections using the href objection for anchor tags. This will only allow links starting with &#8220;www.&#8221; or &#8220;<a href="http://&#038;#8221" rel="nofollow">http://&#038;#8221</a>;. You can modify this if you want to allow others such as ftp etc. Obviously this is to prevent against those href=&#8221;javascript:&#8230;..&#8221; injections.</p>
<p>So now that you got the basics you can go through and figure out the nitty gritty! Remember as one developer wrote in a blurb, DO NOT ever let the attacker no if they failed or passed. Otherwise you&#8217;re basically inviting them to try to figure out your code. You don&#8217;t want to do that!</p>
<p><strong>Please read:<br />
<span style="font-weight:normal;">While I put a great deal of effort into this script, I did not write everything from scratch. A lot of people around the web have helped write the code you see above. I simply tweaked what they had and combined it into a far more secure function. So thanks to everyone who posted the original code that helped me write this. Sadly there are too many to know off hand.</span></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2010/01/17/whitelist-html-tags-advance-methods-for-prevention-against-javascript-injections/feed/</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Enable/Disable .Net controls (Security Tip)</title>
		<link>https://sanzon.wordpress.com/2009/02/05/enabledisable-net-controls-security-tip/</link>
					<comments>https://sanzon.wordpress.com/2009/02/05/enabledisable-net-controls-security-tip/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Thu, 05 Feb 2009 05:53:04 +0000</pubDate>
				<category><![CDATA[.Net Framework 3.5]]></category>
		<category><![CDATA[Asp.Net Framework 2.0]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=103</guid>

					<description><![CDATA[I was just browing around online and found a thread on asp.net&#8217;s forum talking about disabling a textbox for security reasons. Now, I&#8217;m always anal when it comes to security, double checking everything sever side and never assuming the page generated on the clientside will be the way I intended it on the way back. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I was just browing around online and found a thread on asp.net&#8217;s forum talking about disabling a textbox for security reasons.</p>
<p>Now, I&#8217;m always anal when it comes to security, double checking everything sever side and never assuming the page generated on the clientside will be the way I intended it on the way back.</p>
<p>For those who have ever thought of doing this as a quick solution, I&#8217;m sorry, but you&#8217;re wrong. All disabling controls do is create a friendly user interface where a user knows ahead of time they can&#8217;t edit it.</p>
<p>In any browser, such as firefox, with firebug, you can just back the code and reenable it and then alter the text and submit the form. if you failed to double check for changed and access rights, the person will have just hacked your site. Something any kid can do! So don&#8217;t do it! Use it only to make your site more friendly AND NOT for security reasons.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2009/02/05/enabledisable-net-controls-security-tip/feed/</wfw:commentRss>
			<slash:comments>24</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Boolean to Int32 for SQL database. Yes it&#8217;s that easy!</title>
		<link>https://sanzon.wordpress.com/2009/01/29/boolean-to-int32-for-sql-database-yes-its-that-easy/</link>
					<comments>https://sanzon.wordpress.com/2009/01/29/boolean-to-int32-for-sql-database-yes-its-that-easy/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Thu, 29 Jan 2009 23:11:36 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=101</guid>

					<description><![CDATA[I came across a thread on the web browsing around for a solution to another problem when I came across a forum thread that seemed to go on forever about converting a boolean, true/false, to an int, 1/0. I wanted to slap them after seeing how so many people couldn&#8217;t find such a simple answer! [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I came across a thread on the web browsing around for a solution to another problem when I came across a forum thread that seemed to go on forever about converting a boolean, true/false, to an int, 1/0.</p>
<p>I wanted to slap them after seeing how so many people couldn&#8217;t find such a simple answer! So here it is incase you need to know how to do it in only 1 line of code!</p>
<p>convert.toint32(Boolean)</p>
<p>I couldn&#8217;t believe it when I saw people telling the person to use if statements and use a variable to hold the value. Granted it was a small forum, but still it shocks me how little people know about the convert method in .net.</p>
<p>If you want to see what I&#8217;m talking about look here:<br />
<a href="http://www.daniweb.com/forums/showthread.php?t=104189&#038;highlight=asp.net+convernt+boolean+to+integer" rel="nofollow">http://www.daniweb.com/forums/showthread.php?t=104189&#038;highlight=asp.net+convernt+boolean+to+integer</a></p>
<p>It makes me sort of wonder if these people do this for a living&#8230; I hope not&#8230; or else I so need a better job.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2009/01/29/boolean-to-int32-for-sql-database-yes-its-that-easy/feed/</wfw:commentRss>
			<slash:comments>18</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>RegisterForEventValidation and enableEventValidation</title>
		<link>https://sanzon.wordpress.com/2008/11/15/registerforeventvalidation-and-enableeventvalidation/</link>
					<comments>https://sanzon.wordpress.com/2008/11/15/registerforeventvalidation-and-enableeventvalidation/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Sat, 15 Nov 2008 02:22:34 +0000</pubDate>
				<category><![CDATA[.Net Framework 3.5]]></category>
		<category><![CDATA[Asp.Net Framework 2.0]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[clientscript]]></category>
		<category><![CDATA[clientscriptmanager]]></category>
		<category><![CDATA[enableEventValidation]]></category>
		<category><![CDATA[RegisterForEventValidation]]></category>
		<category><![CDATA[validaterequest]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=99</guid>

					<description><![CDATA[Ok first off&#8230; NEVER disable eventvalidation! This is for your own good. I know it&#8217;s very tempting to just type in enableeventvalidation=&#8221;false&#8221; and have the script work just fine. It&#8217;s a major security issue though and so it&#8217;s just best to learn it right the first time and fix it right! So why does this [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Ok first off&#8230; NEVER disable eventvalidation! This is for your own good. I know it&#8217;s very tempting to just type in enableeventvalidation=&#8221;false&#8221; and have the script work just fine. It&#8217;s a major security issue though and so it&#8217;s just best to learn it right the first time and fix it right!</p>
<p>So why does this pesky error appear at times? There are a few reasons in my case, because I had a clientside script being run from a server control. Which caused some messy conflicts. To sold this error it is actually really easy. Just include the following code in your script:</p>
<pre style="background-color:#ccc;">
        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Page.ClientScript.RegisterForEventValidation(tbxSearch.uniqueid)
            MyBase.Render(writer)
        End Sub
</pre>
<p>And that&#8217;s it! Ok, maybe I should explain it. Generally you have to edit the script on the render phase. If you don&#8217;t know the page lifecycle&#8230;. learn it! You&#8217;ll need it! Just google it and you&#8217;ll find a great description on msdn.</p>
<p>So generally we override the render phase. Thus the keyword overrides in the code. The MyBase.Render(writer) line of code is basically&#8230;. what normally happens. In this case right before the render phase goes through we inject a line of code to say, &#8220;Hey, ignore this control! It&#8217;s safe!&#8221; and then the clientscriptmanager will process that control and let it slide pass eventvalidation. Now to do this you have to do it through page.clientscript and use the registerforeventvalidation method to find the specific control you need to allow.</p>
<p>After that test out the page and there shouldn&#8217;t be any problems! oh btw I do typically disable ValidateRequest myself. This generally prevents users from submitting information like &#8220;&lt;script&#8230;..&#8221; into forums and such. Which if you are using proper coding methods you shouldn&#8217;t need to run these training wheels. Eventvalidation is a whole other story since it&#8217;s a lot more work to enforce it strictly behind code.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2008/11/15/registerforeventvalidation-and-enableeventvalidation/feed/</wfw:commentRss>
			<slash:comments>28</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding multiple AsyncPostBackTriggers dynamically</title>
		<link>https://sanzon.wordpress.com/2008/11/12/adding-multiple-asyncpostbacktriggers-dynamically/</link>
					<comments>https://sanzon.wordpress.com/2008/11/12/adding-multiple-asyncpostbacktriggers-dynamically/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Wed, 12 Nov 2008 02:35:48 +0000</pubDate>
				<category><![CDATA[.Net Framework 3.5]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Asp.Net Framework 2.0]]></category>
		<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[ASP.net]]></category>
		<category><![CDATA[AsyncPostBackTrigger]]></category>
		<category><![CDATA[triggers]]></category>
		<category><![CDATA[updatepanel]]></category>
		<category><![CDATA[updatepaneltriggercollection]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=93</guid>

					<description><![CDATA[This one took be a bit of time to figure out, and really can be extremely useful in some cases. This is the situation, you want to set an unknown amount of controls as a triggers to your updatepanel. The problem is you typically have to do this the following way… Dim mytrigger as new [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This one took be a bit of time to figure out, and really can be extremely useful in some cases. This is the situation, you want to set an unknown amount of controls as a triggers to your updatepanel. The problem is you typically have to do this the following way…</p>
<pre style="background-color:#ccc;">Dim mytrigger as new AsyncPostBackTrigger
Mytrigger.ContorlID = “tab1”</pre>
<p>Well this works if you have a set amount of triggers. You just do this each time for each trigger and it works out really well. But what if you don’t know how many controls there are. An example of when? Custom server controls, which I have been learning vigorously these last few months.</p>
<p>In this case we have a property which holds several button inputs, or tabs in my case. Well the problem is the developer can add multiple instances of these tab controls, so exactly how do we link them all to the updatepanel?</p>
<p>The answer is in the UpdatePanelTriggerCollection! This wonderful class is used to hold all the triggers within the updatepanel. So to do this we first create the updatepanel followed by the updatepaneltriggercollection.</p>
<pre style="background-color:#ccc;">Dim upnlContent as new updatepanel
upnlContent.UpdateMode = UpdatePanelUpdateMode.Conditional

Dim triggerCollectionContent as new updatepaneltriggercollection(upnlContent)</pre>
<p>If you notice you must declare an owner to the triggercollection. In this case being upnlContent.</p>
<p>After you setup the triggerCollect you have to create your triggers with the following code:</p>
<pre style="background-color:#ccc;">triggerCollectionContent.Insert(0, New AsyncPostBackTrigger)
CType(triggerCollectionContent.Item(0), AsyncPostBackTrigger).ControlID = "tab1"</pre>
<p>The first line creates a new entry into the collection as a new trigger. The second line sets the controlID for the trigger. If you notice we didn’t have to assign it a variable name! Meaning it’s an array of triggers. So once you have finished inserting all of your triggers using a for loop you then go ahead and go back through that collection and add them to the updatepanel one by one as follows:</p>
<pre style="background-color:#ccc;">upnlContent.triggers.add(triggerCollectionContent.Item(0))</pre>
<p>You use the same loop to add them to the updatepanel. Hope that helps you all out!</p>
<p>NOTE: When using this method with a for loop using control.controls.item(i), make sure to use an if statement to check the control type using control.controls.item(i).gettype is gettype(controltype)!!! And make sure to use i instead of 0 if you&#8217;re looping.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2008/11/12/adding-multiple-asyncpostbacktriggers-dynamically/feed/</wfw:commentRss>
			<slash:comments>42</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Imposing functions onto document.body.onmousemove</title>
		<link>https://sanzon.wordpress.com/2008/10/16/imposing-functions-onto-documentbodyonmousemove/</link>
					<comments>https://sanzon.wordpress.com/2008/10/16/imposing-functions-onto-documentbodyonmousemove/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Thu, 16 Oct 2008 20:53:17 +0000</pubDate>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[add]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[document.body]]></category>
		<category><![CDATA[document.body.onmousemove]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[impose]]></category>
		<category><![CDATA[onmousemove]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=90</guid>

					<description><![CDATA[My last post went over how to handle onscroll with window.onscroll and adding an additional function to an existing function. Well with document.body.onmousemove there is a bit of a problem with Firefox. In order for the script to work you need to determine if a value already exists. This is where the problem lies with [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>My last post went over how to handle onscroll with window.onscroll and adding an additional function to an existing function. Well with document.body.onmousemove there is a bit of a problem with Firefox.</p>
<p>In order for the script to work you need to determine if a value already exists. This is where the problem lies with FF. To get the value, the only way to do it that I know works is&#8230;</p>
<pre style="background-color:#bbb;">if (document.body.getAttribute("onmousemove")) { }</pre>
<p>Once you have that going you can simply do the same but&#8230;  but it requires a bit more work sadly.</p>
<p>As with the previous example in the last post, with onscroll, you always need to have it referenced as </p>
<pre style="background-color:#bbb;">function() { /* your code */ }</pre>
<p>In IE and most other browseres, besides FF, the returned code will always be treated as an anyomous function. Meaning when you call back document.body.onmousemove it is treated as a function which requires you to call&#8230;. document.body.onmousemove(), in FF it is returned as document.body.onmousemove without the () so the next part of this puzzle is to determine the browser type. In this case I tested for FF by using the following&#8230;</p>
<pre style="background-color:#bbb;">if (navigator.userAgent.indexOf("Firefox")!=-1) {
 //FF code
} else {
 //Non-FF code
}</pre>
<p>The final result of combing these methods is:</p>
<pre style="background-color:#bbb;">if (document.body.getAttribute("onmousemove")) {
   var MouseMoveCode = eval(document.body.onmousemove);
   if (navigator.userAgent.indexOf("Firefox")!=-1) {
      var MouseMoveEvent = function(event) { 
         dragDiv(event,CustomControls.OverlayMenu.MouseMoveCode)};
         document.body.onmousemove = MouseMoveEvent;
   } else {                
      MouseMoveEvent = function(event) { 
      dragDiv(event,MouseMoveCode())};
      document.body.onmousemove = MouseMoveEvent;
   }
} else {
   document.body.onmousemove = function(event) { dragDiv(event) };
}</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2008/10/16/imposing-functions-onto-documentbodyonmousemove/feed/</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Handling form data issues with FireFox on page refresh</title>
		<link>https://sanzon.wordpress.com/2008/10/16/handling-form-data-issues-with-firefox-on-page-refresh/</link>
					<comments>https://sanzon.wordpress.com/2008/10/16/handling-form-data-issues-with-firefox-on-page-refresh/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Thu, 16 Oct 2008 09:08:08 +0000</pubDate>
				<category><![CDATA[Asp.Net Framework 2.0]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[refresh]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=88</guid>

					<description><![CDATA[If you have ever noticed how FireFox maintains form data on a page refresh, it can causes some issues at times when handling .net code that uses these inputs to render javascript code after the page loads. To get around this, you can simply use the following code with a scriptmanager control: If Not Page.IsPostBack [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>If you have ever noticed how FireFox maintains form data on a page refresh, it can causes some issues at times when handling .net code that uses these inputs to render javascript code after the page loads.</p>
<p>To get around this, you can simply use the following code with a scriptmanager control:</p>
<pre style="background-color:#bbb;">If Not Page.IsPostBack Then 
   ScriptManager.RegisterStartupScript(Page, Page.GetType(), _
   "ScriptManager_myFunction", "document.getElementById('" &amp; _
   myControl.ClientID &amp; "').value = 'default value';", True)
End If</pre>
<p>You can also clear the form control value, but I typically do not recommend this action since it defeats the advantages associated with firefox maintaining form data on refresh.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2008/10/16/handling-form-data-issues-with-firefox-on-page-refresh/feed/</wfw:commentRss>
			<slash:comments>30</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
		<item>
		<title>Combining/Imposing Event Code in JavaScript</title>
		<link>https://sanzon.wordpress.com/2008/10/16/combiningimposing-event-code-in-javascript/</link>
					<comments>https://sanzon.wordpress.com/2008/10/16/combiningimposing-event-code-in-javascript/#comments</comments>
		
		<dc:creator><![CDATA[sanzon]]></dc:creator>
		<pubDate>Thu, 16 Oct 2008 07:35:44 +0000</pubDate>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[combine]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[impose]]></category>
		<category><![CDATA[window]]></category>
		<guid isPermaLink="false">http://sanzon.wordpress.com/?p=81</guid>

					<description><![CDATA[In JavaScript there may be times you want to combine code onto an existing window event. In this case we will use window.onscroll. In this example we already have assigned window.onscroll as the following: window.onscroll = function() { setTimeout("document.getElementById('myDiv').style.color='red';",200); setTimeout("document.getElementById('myDiv').style.color='green';",400); }; This causes the text color to blink within our div as we scroll. Of [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In JavaScript there may be times you want to combine code onto an existing window event. In this case we will use window.onscroll.</p>
<p>In this example we already have assigned window.onscroll as the following:</p>
<pre style="background-color:#bbb;">window.onscroll = function() {  
     setTimeout("document.getElementById('myDiv').style.color='red';",200);
     setTimeout("document.getElementById('myDiv').style.color='green';",400);  
};</pre>
<p>This causes the text color to blink within our div as we scroll. Of course this is only for example and serves no practical use&#8230; normally at least. Anyway, now we want to combine this with some other code.</p>
<p>So we now want to impose the new onscroll code:</p>
<pre style="background-color:#bbb;">function() { moveDiv() }</pre>
<p>moveDiv in this case moves the div so it is always on screen while you move. (fyi, this is how I personally get around IE5&#8217;s lack of support for position:fixed)</p>
<p>So how do we impose our old code onto the new code? Well it&#8217;s kind of strange, but we have to be a bit sneaky about it and take advantage of JavaScript&#8217;s JSON logic. To do this, we simply add the old code within the declaration of the new code, such as:</p>
<pre style="background-color:#bbb;">var ScrollCode = eval(window.onscroll);
window.onscroll = function() { moveDiv(ScrollCode()) };</pre>
<p>Yes I am using eval, and yes most people hate using eval, but if used correct it is actually very useful! So there is no harm in this case since the eval code does not involve any sort of user input.</p>
<p>So what happens in this code is simple. We call the new function moveDiv which references the variable ScrollCode which calls the function for the current onscroll code. As a result both codes are ran at the same time. This makes adding new code easy, and you can continue to add code in this same manor. It just continues to impose the code onto each other.</p>
<p>Anyway hope this helps, and please let me know if you have any issues with it. Good luck.</p>
<p>PS: Note that this method is meant to be used with window events. click events do not always require function usage. (i.e. window.onscroll = function() {};) Most window events do require this on modern browsers.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sanzon.wordpress.com/2008/10/16/combiningimposing-event-code-in-javascript/feed/</wfw:commentRss>
			<slash:comments>19</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/c6dcbf6a2ff397bf61effcbe338df1304e265b8001f7efe2c9e999db0c4a6dcd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Tom</media:title>
		</media:content>
	</item>
	</channel>
</rss>
