<?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:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Chris's ASP.Net Blog</title>
	<atom:link href="http://snakeman65.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://snakeman65.wordpress.com</link>
	<description>Some of the wierdness of asp.net exposed! Plus handy code samples.</description>
	<lastBuildDate>Tue, 17 Jun 2008 10:53:13 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='snakeman65.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/096ba5bbdf125084744a014d7c5d8824?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Chris's ASP.Net Blog</title>
		<link>http://snakeman65.wordpress.com</link>
	</image>
			<item>
		<title>Clever Membership Providers</title>
		<link>http://snakeman65.wordpress.com/2008/05/01/clever-membership-providers/</link>
		<comments>http://snakeman65.wordpress.com/2008/05/01/clever-membership-providers/#comments</comments>
		<pubDate>Thu, 01 May 2008 10:02:50 +0000</pubDate>
		<dc:creator>snakeman65</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[active directory]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://snakeman65.wordpress.com/?p=7</guid>
		<description><![CDATA[I have recently been creating membership/role providers for use with the content management system where I work. We use active directory to authenticate users, however, we have some generic users that need to authenticate and we don&#8217;t really want to create them in our AD. The solution: Have my login page attempt to authenticate with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=snakeman65.wordpress.com&blog=670954&post=7&subd=snakeman65&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have recently been creating membership/role providers for use with the content management system where I work. We use active directory to authenticate users, however, we have some generic users that need to authenticate and we don&#8217;t really want to create them in our AD. The solution: Have my login page attempt to authenticate with ad and if it fails, have it check the sql membership provider. To do this, I override the Authenticate method for the login control on our login page like so:</p>
<pre class="brush: csharp;">

protected void Authenticate(object sender, AuthenticateEventArgs e)
        {
            bool Authenticated = false;
            MembershipProvider provider;
            provider = Membership.Providers[&quot;MyAdMembershipProvider&quot;];
            Authenticated = provider.ValidateUser(Login1.UserName, Login1.Password);
            if (!Authenticated)
            {
                provider = Membership.Providers[&quot;SQLProvider&quot;];
                Authenticated = provider.ValidateUser(Login1.UserName, Login1.Password);
            }
            e.Authenticated = Authenticated;
        }
</pre>
<p>Of course, there may be some sort of security implication to this but I think its ok. If you know otherwise or know a better way of doing this, feel free to leave a comment!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/snakeman65.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/snakeman65.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/snakeman65.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/snakeman65.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/snakeman65.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/snakeman65.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/snakeman65.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/snakeman65.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/snakeman65.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/snakeman65.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/snakeman65.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/snakeman65.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=snakeman65.wordpress.com&blog=670954&post=7&subd=snakeman65&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://snakeman65.wordpress.com/2008/05/01/clever-membership-providers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b5bafc994cfb82b4f73738e9aa3a4b3d?s=96&#38;d=identicon" medium="image">
			<media:title type="html">snakeman65</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic Javascript Dropdowns</title>
		<link>http://snakeman65.wordpress.com/2008/04/29/dynamic-javascript-dropdowns/</link>
		<comments>http://snakeman65.wordpress.com/2008/04/29/dynamic-javascript-dropdowns/#comments</comments>
		<pubDate>Tue, 29 Apr 2008 14:39:59 +0000</pubDate>
		<dc:creator>snakeman65</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[dropdowns]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://snakeman65.wordpress.com/?p=6</guid>
		<description><![CDATA[So I was recently creating a form with dynamic dropdown lists (populated clientside by javascript). Unfortunately, because the options in this box don&#8217;t match what the server thinks are the options the first error you get is along the lines of:
&#8216;dropReasonCode&#8217; has a SelectedValue which is invalid because it does not exist in the list [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=snakeman65.wordpress.com&blog=670954&post=6&subd=snakeman65&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>So I was recently creating a form with dynamic dropdown lists (populated clientside by javascript). Unfortunately, because the options in this box don&#8217;t match what the server thinks are the options the first error you get is along the lines of:</p>
<p><em><span style="font-size:11pt;">&#8216;dropReasonCode&#8217; has a SelectedValue which is invalid because it does not exist in the list of items.<br />
Parameter name: value</span></em><span style="font-size:11pt;"> </span></p>
<p>The way to get around this is to register all of the possible options in the render event of the page like so:</p>
<pre class="brush: csharp;">
protected override void Render(HtmlTextWriter writer)
        {
base.Render(writer);
Page.ClientScript.RegisterForEventValidation(yourdropdownboxname.UniqueID, &quot;0001&quot;);
Page.ClientScript.RegisterForEventValidation(yourdropdownboxname.UniqueID, &quot;0002&quot;);
etc....
        }
</pre>
<p>This allows the page to post back, unfortunately, when you look at the selectedindex/selectedvalue of the dropdown you&#8217;ll find that it has ignored any selection that wasn&#8217;t in the box when the server created it! Now there are lots of ways around this, I know of two which I will detail:</p>
<ul>
<li>Use javascript attached to the onchange of the dropdown to copy the value to a hidden field then read from that on the server.</li>
</ul>
<p>I used to use this but I now feel that this is too clunky but if its what you want here&#8217;s the code I used:</p>
<p>In the codebehind:</p>
<pre class="brush: csharp;">
if (txtDate.Attributes[&quot;onchange&quot;] == null)
            {
                dropdownname.Attributes.Add(&quot;onchange&quot;, &quot;javascript:copyvalue(this.options[this.selectedIndex].value);&quot;);
            }
</pre>
<p>and in the front:</p>
<pre class="brush: jscript;">
function copydate(selected)
{
document.getElementById(&quot;&lt;%=hiddenfield.ClientID %&gt;&quot;).value = selected;
}
</pre>
<ul>
<li>Use the Request.Form collection to read the values</li>
</ul>
<p><span style="text-decoration:line-through;">This solution is much more elegant (though i&#8217;m sure there is something better still). However, there is a gotcha, in asp.net you can&#8217;t just use the id of the object, you have to use its client id, further to this, the client id will have underscores in it while the request.form collection uses $ symbols so this has to be dealt with, leaving the final code to retrieve a value:<br />
</span></p>
<p>Update: The reason I was having to use the Replace function (which subsequently broke when I moved server!) was because the request.form collection doesn&#8217;t use clientid it uses uniqueid!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/snakeman65.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/snakeman65.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/snakeman65.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/snakeman65.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/snakeman65.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/snakeman65.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/snakeman65.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/snakeman65.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/snakeman65.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/snakeman65.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/snakeman65.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/snakeman65.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=snakeman65.wordpress.com&blog=670954&post=6&subd=snakeman65&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://snakeman65.wordpress.com/2008/04/29/dynamic-javascript-dropdowns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b5bafc994cfb82b4f73738e9aa3a4b3d?s=96&#38;d=identicon" medium="image">
			<media:title type="html">snakeman65</media:title>
		</media:content>
	</item>
	</channel>
</rss>