<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>aspnet &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://wordpress.com/tag/aspnet/</link>
	<description>Feed of posts on WordPress.com tagged "aspnet"</description>
	<pubDate>Mon, 13 Oct 2008 23:12:19 +0000</pubDate>

	<generator>http://wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Querying WHOIS datbases int ASP.NET]]></title>
<link>http://aspguy.wordpress.com/?p=149</link>
<pubDate>Mon, 13 Oct 2008 18:37:15 +0000</pubDate>
<dc:creator>Aref Karimi</dc:creator>
<guid>http://aspguy.ar.wordpress.com/2008/10/13/querying-whois-datbases-int-aspnet/</guid>
<description><![CDATA[A while back I was involved in developing a web site for a Domain and Hosting reseller. In that proj]]></description>
<content:encoded><![CDATA[<p>A while back I was involved in developing a web site for a Domain and Hosting reseller. In that project I needed to create a "Find A Domain"  section in which the customer could check to see if a domain name exists.</p>
<p>I made a exhaustive research and figured out that each Who is server maintains a list of certain domain types. For example,  Whois.net can whois only .COM, .NET and .ORG domains.</p>
<p>Many posts over the internet, including blogs.msdn.com,  also says that to query a who is database one should connect to the whois server through a TCP/IP conenction (usually via port 43).</p>
<p>All the above issues make Whois action fairly difficult to perform. Luckily, today I came across a very nice web site which provides a Whois SOAP web service.  To see the details of the service check this link:</p>
<p><a href="http://www.webservicex.net/whois.asmx?op=GetWhoIS" target="_blank">http://www.webservicex.net/whois.asmx?op=GetWhoIS</a></p>
<p>This web service searches all the who is databases to look up the domain name you provide. Therefore, you will not need to search several who is databases.</p>
<p>To Whois a domain name, you should pass a 'hostname' parameter to the service:</p>
<p><span style="color:#ff00ff;">http://www.webservicex.net/whois.asmx?Hostname=Microsoft.com</span></p>
<p>You can use this web service simply via a GET or a POST method as well as making a reference to it via Visual Studio and call its GetWhoIS metho. As I mentioned in the previous post (about REST web services), I prefer to get the who is answer using XElement.Load method. For example we may write the following method for whoising:</p>
<p><span style="color:#ff0000;">public static string WhoIs(string hostname)<br />
{<br />
XElement WhoisResult = XElement.Load(</span></p>
<p><span style="color:#ff0000;"> "http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=microsoft.com");<br />
return WhoisResult.ToString();<br />
}</span></p>
<p>Each Who is server returns a different response. Therefore, to develop a method which indicates wheather a domain name exits or not, we should look for a common string value in the WhoIS response. For example the 'NAME SERVER' seems to be a common string. There fore, a domain lookup function can be written this way:</p>
<p><span style="color:#ff0000;">public static bool IsDomainTaken(string hostname)<br />
{<br />
return WhoIs(hostname).ToUpper().Contains("NAME SERVER");<br />
}</span></p>
<p>As I told you, this web service seems to query several WhoIS server, thus the GetWhoIS method is a little bit time consuming.</p>
<p><strong>P.S. Try to Whois Microsoft.com, the result is pretty funny:</strong></p>
<pre><span style="color:#800000;">Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

MICROSOFT.COM.ZZZZZZ.MORE.DETAILS.AT.WWW.BEYONDWHOIS.COM
MICROSOFT.COM.ZZZZZ.GET.LAID.AT.WWW.SWINGINGCOMMUNITY.COM
MICROSOFT.COM.ZZZZZ.DOWNLOAD.MOVIE.ONLINE.ZML2.COM
MICROSOFT.COM.ZZZOMBIED.AND.HACKED.BY.WWW.WEB-HACK.COM
MICROSOFT.COM.ZZZ.IS.0WNED.AND.HAX0RED.BY.SUB7.NET
MICROSOFT.COM.WILL.LIVE.FOREVER.BECOUSE.UNIXSUCKS.COM
MICROSOFT.COM.WILL.BE.SLAPPED.IN.THE.FACE.BY.MY.BLUE.VEINED.SPANNER.NET
MICROSOFT.COM.WILL.BE.BEATEN.WITH.MY.SPANNER.NET
MICROSOFT.COM.WAREZ.AT.TOPLIST.GULLI.COM
MICROSOFT.COM.TOTALLY.SUCKS.S3U.NET
MICROSOFT.COM.SOFTWARE.IS.NOT.USED.AT.REG.RU
MICROSOFT.COM.SHOULD.GIVE.UP.BECAUSE.LINUXISGOD.COM
MICROSOFT.COM.RAWKZ.MUH.WERLD.MENTALFLOSS.CA
MICROSOFT.COM.OHMYGODITBURNS.COM
MICROSOFT.COM.MORE.INFO.AT.WWW.BEYONDWHOIS.COM
MICROSOFT.COM.LOVES.ME.KOSMAL.NET
MICROSOFT.COM.LIVES.AT.SHAUNEWING.COM
MICROSOFT.COM.IS.NOT.YEPPA.ORG
MICROSOFT.COM.IS.NOT.HOSTED.BY.ACTIVEDOMAINDNS.NET
MICROSOFT.COM.IS.IN.BED.WITH.CURTYV.COM
MICROSOFT.COM.IS.HOSTED.ON.PROFITHOSTING.NET
MICROSOFT.COM.IS.GOD.BECOUSE.UNIXSUCKS.COM
MICROSOFT.COM.IS.A.STEAMING.HEAP.OF.FUCKING-BULLSHIT.NET
MICROSOFT.COM.IS.A.MESS.TIMPORTER.CO.UK
MICROSOFT.COM.HAS.ITS.OWN.CRACKLAB.COM
MICROSOFT.COM.HAS.A.PRESENT.COMING.FROM.HUGHESMISSILES.COM
MICROSOFT.COM.FILLS.ME.WITH.BELLIGERENCE.NET
MICROSOFT.COM.CAN.GO.FUCK.ITSELF.AT.SECZY.COM

</span>
<span style="color:#800000;"><span style="color:#000000;">Bye for now.</span>
</span></pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[They are never locked - web.config]]></title>
<link>http://epuri.wordpress.com/?p=33</link>
<pubDate>Mon, 13 Oct 2008 17:45:16 +0000</pubDate>
<dc:creator>Epuri</dc:creator>
<guid>http://epuri.ar.wordpress.com/2008/10/13/they-are-never-locked-webconfig/</guid>
<description><![CDATA[web.config settings can be updated at any point of time, even while application is is running. If th]]></description>
<content:encoded><![CDATA[<p><strong>web.config</strong> settings can be updated at any point of time, even while application is is running. If there are any requests currently under way, they'll continue to use the old settings, while new requests will get the changed settings right away.</p>
<p><strong>web.config </strong>file is case sensative as like other xml files.</p>
<p><strong>Following three sections are more important to web developers:</strong></p>
<ol>
<li>&#60;appSettings&#62; - All the custome/miscellaneous pieces of information can be set here.</li>
<li>&#60;connectionSettings&#62; - Holds the all connection information for accessing database.</li>
<li>&#60;system.web&#62; - Holds every ASP.Net setting that need to be configured for web application. For example it holds major sub sections like &#60;customErrors&#62;, &#60;authorization&#62; and &#60;authentication&#62; etc..</li>
</ol>
<p>Generally every web server starts with some basic settings. These basic settings are typically stored in two files at following location: <strong>C:\Windows\Microsoft.NET\Framework\v####\Config</strong></p>
<p>These two config files are namely machine.config and web.config and these files are locked and not open for editing purpose by any developer. We can override these settings using application level <strong>web.config </strong>file.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ASP.NET Best practices - Publish website IIS6.0]]></title>
<link>http://thirul.wordpress.com/?p=21</link>
<pubDate>Mon, 13 Oct 2008 14:33:44 +0000</pubDate>
<dc:creator>thirul</dc:creator>
<guid>http://thirul.ar.wordpress.com/2008/10/13/aspnet-best-practices-publish-website-iis60/</guid>
<description><![CDATA[Best practices for creating websites in IIS 6.0
by: omar
Every time I create an IIS website, I do so]]></description>
<content:encoded><![CDATA[<h2>Best practices for creating websites in IIS 6.0</h2>
<p>by: omar</p>
<p>Every time I create an IIS website, I do some steps, which I consider as best practice for creating any IIS website for better performance, maintainability, and scalability. Here' re the things I do:</p>
<p><strong>Create a separate application pool for each web application</strong></p>
<p>I always create separate app pool for each web app because I can select different schedule for app pool recycle. Some heavy traffic websites have long recycle schedule where low traffic websites have short recycle schedule to save memory. Moreover, I can choose different number of processes served by the app pool. Applications that are made for web garden mode can benefit from multiple process where applications that use in-process session, in memory cache needs to have single process serving the app pool. Hosting all my application under the <span style="text-decoration:underline;">DefaultAppPool</span> does not give me the flexibility to control these per site.</p>
<p>The more app pool you create, the more ASP.NET threads you make available to your application. Each <span style="text-decoration:underline;">w3wp.exe</span> has it's own thread pool. So, if some application is congesting particular <span style="text-decoration:underline;">w3wp.exe</span> process, other applications can run happily on their separate <span style="text-decoration:underline;">w3wp.exe</span> instance, running under separate app pool. Each app pool hosts its own <span style="text-decoration:underline;">w3wp.exe</span> instance.</p>
<p>So, my rule of thumb: Always create new app pool for new web applications and name the app pool based on the site's domain name or some internal name that makes sense. For example, if you are creating a new website alzabir.com, name the app pool alzabir.com to easily identify it.</p>
<p>Another best practice: Disable the <span style="text-decoration:underline;">DefaultAppPool</span> so that you don't mistakenly keep adding sites to <span style="text-decoration:underline;">DefaultAppPool</span>.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_4.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_1.png" border="0" alt="image" width="664" height="340" /></a></p>
<p>First you create a new application pool. Then you create a new Website or Virtual Directory, go to Properties -&#62; Home Directory tab -&#62; Select the new app pool.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_6.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_2.png" border="0" alt="image" width="620" height="501" /></a></p>
<p><strong>Customize Website properties for performance, scalability and maintainability</strong></p>
<p>First you map the right host headers to your website. In order to do this, go to WebSite tab and click on "Advanced" button. Add mapping for both domain.com and <a href="http://www.domain.com/">www.domain.com</a>. Most of the time, people forget to map the domain.com. Thus many visitors skip typing the www prefix and get no page served.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_10.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_4.png" border="0" alt="image" width="648" height="493" /></a></p>
<p>Next turn on some log entries:</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_12.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_5.png" border="0" alt="image" width="605" height="458" /></a></p>
<p>These are very handy for analysis. If you want to measure your bandwidth consumption for specific sites, you need the Bytes Sent. If you want to measure the execution time of different pages and find out the slow running pages, you need Time Taken. If you want to measure unique and returning visitors, you need the Cookie. If you need to know who is sending you most traffic - search engines or some websites, you need the Referer. Once these entries are turned on, you can use variety of Log Analysis tools to do the analysis. For example, <a title="s" href="http://awstats.sourceforge.net/">open source AWStats</a>.</p>
<p>But if you are using Google Analytics or something else, you should have these turned off, especially the Cookie and Referer because they take quite some space on the log. If you are using ASP.NET Forms Authentication, the gigantic cookie coming with every request will produce gigabytes of logs per week if you have a medium traffic website.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_14.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_6.png" border="0" alt="image" width="473" height="269" /></a></p>
<p>This is kinda no brainer. I add Default.aspx as the default content page so that, when visitors hit the site without any .aspx page name, e.g. alzabir.com, they get the default.aspx served.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_16.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_7.png" border="0" alt="image" width="475" height="461" /></a> </p>
<p>Things I do here:</p>
<ul>
<li>Turn on Content Expiration. This makes static files remain in browser cache for 30 days and browser serves the files from its own cache instead of hitting the server. As a result, when your users revisit, they don't download all the static files like images, javascripts, css files again and again. This one setting significantly improves your site's performance.</li>
<li>Remove the <span style="text-decoration:underline;">X-Powered-By: ASP.NET</span> header. You really don't need it unless you want to attach Visual Studio Remote Debugger to your IIS. Otherwise, it's just sending 21 bytes on every response.</li>
<li>Add "From" header and set the server name. I do this on each webserver and specify different names on each box. It's handy to see from which servers requests are being served. When you are trying to troubleshoot load balancing issues, it comes handy to see if a particular server is sending requests.</li>
</ul>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_18.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_8.png" border="0" alt="image" width="538" height="465" /></a></p>
<p>I set the 404 handler to some ASPX so that I can show some custom error message. There's a 404.aspx which shows some nice friendly message and suggests some other pages that user can visit. However, another reason to use this custom mapping is to serve extensionless URL from IIS. <a href="http://msmvps.com/blogs/omar/archive/2007/04/29/serve-extensionless-url-from-asp-net-without-using-isapi-module-or-iis-6-wildcard-mapping.aspx">Read this blog post for details</a>.</p>
<p><a href="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_20.png"><img style="border-width:0;" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/omar.BestpracticesforcreatingwebsitesinIIS6.0_5F00_CC6A/image_5F00_thumb_5F00_9.png" border="0" alt="image" width="471" height="459" /></a></p>
<p>Make sure to set ASP.NET 2.0 for your ASP.NET 2.0, 3.0 and 3.5 websites.</p>
<p>Finally, you must, I repeat you "MUST" <a href="http://msmvps.com/blogs/omar/archive/2006/08/10/iis-6-compression-quickest-and-effective-way-to-do-it-for-asp-net-compression.aspx">turn on IIS 6.0 gzip compression</a>. This turns on the Volkswagen V8 engine that is built into IIS to make your site</p>
<p> </p>
<p>original  link from:</p>
<p><a href="http://msmvps.com/blogs/omar/archive/2008/10/04/best-practices-for-creating-websites-in-iis-6-0.aspx">http://msmvps.com/blogs/omar/archive/2008/10/04/best-practices-for-creating-websites-in-iis-6-0.aspx</a>?</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[How to Only Allow Numbers in A TextBox]]></title>
<link>http://fleasharp.wordpress.com/?p=33</link>
<pubDate>Mon, 13 Oct 2008 14:23:12 +0000</pubDate>
<dc:creator>fleasharp</dc:creator>
<guid>http://fleasharp.ar.wordpress.com/2008/10/13/how-to-only-allow-numbers-in-a-textbox/</guid>
<description><![CDATA[I came across a problem the other day. I was working on a ASP.NET application written on the .NET 1.]]></description>
<content:encoded><![CDATA[<p>I came across a problem the other day. I was working on a ASP.NET application written on the .NET 1.1 Framework and I need to restrict two text box controls to only allow numbers. Being written for 1.1, I did not have access to the slick AJAX Control Toolkit which I could had easily thrown on a extender to force only numbers, thus I had to resort to good old JavaScript!</p>
<p>There actually were lots of examples of doing this on the Internet, but it was challenging to find one that worked period or would work in multiple browsers! Finally, after doing extensive searches and tweaks, here is the final function I used to restrict a text box to only accept numbers:</p>
<p>Javascript Function</p>
<p>[sourcecode language='jscript']</p>
<p>// A function that only allows numbers to be typed into a text field.<br />
function NumberValidation(event)<br />
{<br />
var charCode = (event.which) ? event.which : event.keyCode;</p>
<p>return !(charCode > 31 && (charCode < 48 &#124;&#124; charCode > 57));<br />
}</p>
<p>[/sourcecode]<br />
ASP.NET Code</p>
<p>[sourcecode language='csharp']</p>
<p><asp:TextBox ID="PageSize" Runat="server" style="width:30px;" MaxLength="3" OnKeyPress="return NumberValidation(event);"></asp:TextBox><br />
[/sourcecode]</p>
<p>*Note: Even though Visual Studio will indicate you cannot have OnKeyPress in the aspx, you can still put it there and it will work.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Response.Redirect VS Server.Transfer]]></title>
<link>http://ajaymatharu.wordpress.com/?p=201</link>
<pubDate>Mon, 13 Oct 2008 05:22:04 +0000</pubDate>
<dc:creator>matharuajay</dc:creator>
<guid>http://ajaymatharu.ar.wordpress.com/2008/10/13/responseredirect-vs-servertransfer/</guid>
<description><![CDATA[Response.Redirect simply sends a message down to the browser, telling it to move to another page. So]]></description>
<content:encoded><![CDATA[<p><span style="font-family:Verdana,Arial,Helvetica;"><span style="text-decoration:underline;">Response.Redirect</span> simply sends a message down to the browser, telling it to move to another page. So, you may run code like: </span></p>
<pre><span style="font-family:Verdana,Arial,Helvetica;">Response.Redirect("Form2.aspx")</span></pre>
<p><span style="font-family:Verdana,Arial,Helvetica;">or</span></p>
<pre><span style="font-family:Verdana,Arial,Helvetica;">Response.Redirect("http://www.yahoo.com/")</span></pre>
<p><span style="font-family:Verdana,Arial,Helvetica;">to send the user to another page.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;"><span style="text-decoration:underline;">Server.Transfer</span> is similar in that it sends the user to another page with a statement such as <span style="text-decoration:underline;">Server.Transfer("Form2.aspx")</span>. However, the statement has a number of distinct advantages and disadvantages.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">Firstly, transferring to another page using <span style="text-decoration:underline;">Server.Transfer</span> conserves server resources. Instead of telling the browser to redirect, it simply changes the "focus" on the Web server and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">But watch out: because the "transfer" process can work on only those sites running on the server, you can't use <span style="text-decoration:underline;">Server.Transfer</span> to send the user to an external site. <span style="text-decoration:underline;">Only Response.Redirect</span> can do that.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">Secondly, <span style="text-decoration:underline;">Server.Transfer</span> maintains the original URL in the browser. This can really help streamline data entry techniques, although it may make for confusion when debugging.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">That's not all: The <span style="text-decoration:underline;">Server.Transfer</span> method also has a second parameter—"preserveForm". If you set this to <span style="text-decoration:underline;">True</span>, using a statement such as <span style="text-decoration:underline;">Server.Transfer("Form2.aspx", True)</span>, the existing query string and any form variables will still be available to the page you are transferring to.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">For example, if your WebForm1.aspx has a TextBox control called TextBox1 and you transferred to WebForm2.aspx with the <span style="text-decoration:underline;">preserveForm</span> parameter set to <span style="text-decoration:underline;">True</span>, you'd be able to retrieve the value of the original page TextBox control by referencing <span style="text-decoration:underline;">Request.Form("TextBox1")</span>.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">This technique is great for wizard-style input forms split over multiple pages. But there's another thing you'll want to watch out for when using the <span style="text-decoration:underline;">preserveForm</span> parameter. ASP.NET has a bug whereby, in certain situations, an error will occur when attempting to transfer the form and query string values. You'll find this documented at <a href="http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920" target="new">http://support.microsoft.com/default.aspx?id=kb;en-us;Q316920</a>.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">The unofficial solution is to set the <span style="text-decoration:underline;">enableViewStateMac</span> property to <span style="text-decoration:underline;">True</span> on the page you'll be transferring to, then set it back to <span style="text-decoration:underline;">False</span>. This records that you want a definitive <span style="text-decoration:underline;">False</span> value for this property and resolves the bug.</span></p>
<p><span style="font-family:Verdana,Arial,Helvetica;">So, in brief: <span style="text-decoration:underline;">Response.Redirect</span> simply tells the browser to visit another page. <span style="text-decoration:underline;">Server.Transfer</span> helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables.</span></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[C#, ASP.NET - Listando pastas e arquivos de um diretório]]></title>
<link>http://foreachcode.wordpress.com/?p=30</link>
<pubDate>Mon, 13 Oct 2008 02:23:07 +0000</pubDate>
<dc:creator>alexvip</dc:creator>
<guid>http://foreachcode.ar.wordpress.com/2008/10/13/c-aspnet-listando-pastas-e-arquivos-de-um-diretorio/</guid>
<description><![CDATA[Aqui está uma forma simples de listar o conteúdo (diretórios e arquivos) de uma pasta, transforma]]></description>
<content:encoded><![CDATA[<p>Aqui está uma forma simples de listar o conteúdo (diretórios e arquivos) de uma pasta, transformando os arquivos em registro de uma DataTable e associá-la a um gridview. Com alguns comandos dentro do evento RowDataBound do GridView de destino, você pode criar um sistema de navegação entre os arquivos do seu website. Depois eu posto uma versão otimizada. O objeto DiretoryInfo é utilizado para listar as pastas e o objeto FileInfo para listar e obter informações sobre os arquivos.</p>
<p>"code with no comment rox!" - <em>Alex</em></p>
<p>[]'s</p>
<pre style="background-color:#f5f5f5;border:1px dashed;color:blue;padding:2px 5px 5px;">protected void Page_Load(object sender, EventArgs e)
{
    loadFolder(GridView1, Server.MapPath("."));
}

public void loadFolder(GridView gv_arquivos, String folder)
{

    DirectoryInfo pasta = new DirectoryInfo(folder);
    DirectoryInfo[] subPastas = pasta.GetDirectories();
    FileInfo[] arquivos = pasta.GetFiles();

    DataTable dt = new DataTable();

    dt.Columns.Add("Nome");
    dt.Columns.Add("Tamanho");
    dt.Columns.Add("Tipo");
    dt.Columns.Add("Modificado");
    dt.Columns.Add("Action");

    if (folder != "")
    {
        DataRow dr1 = dt.NewRow();
        dr1["Nome"] = "../";

        dr1["Tamanho"] = "";
        dr1["Tipo"] = "";
        dr1["Modificado"] = "";
        dr1["Action"] = "";

        dt.Rows.Add(dr1);
    }
    foreach (DirectoryInfo dir in subPastas)
    {
        DataRow dr = dt.NewRow();
        dr["Nome"] = "/" + dir.Name;
        dr["Tamanho"] = "-";
        dr["Tipo"] = "Diretório";
        dr["Modificado"] = dir.LastWriteTime.ToString("dd/MM/yyyy");
        dr["Action"] = "";

        dt.Rows.Add(dr);
    }

    foreach (FileInfo file in arquivos)
    {
        DataRow dr = dt.NewRow();
        dr["Nome"] = file.Name;
        dr["Tamanho"] = Convert.ToString(file.Length / 1024) + " kb";
        dr["Tipo"] = file.Extension;
        dr["Modificado"] = file.LastWriteTime.ToString("dd/MM/yyyy");
        dr["Action"] = "";

        dt.Rows.Add(dr);
    }

    gv_arquivos.DataSource = dt;
    gv_arquivos.DataBind();

}</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[What is cdcab7d2?]]></title>
<link>http://amiraryani.wordpress.com/2008/10/13/what-is-cdcab7d2/</link>
<pubDate>Mon, 13 Oct 2008 00:31:28 +0000</pubDate>
<dc:creator>amiraryani</dc:creator>
<guid>http://amiraryani.ar.wordpress.com/2008/10/13/what-is-cdcab7d2/</guid>
<description><![CDATA[Pre-compiling an ASP.Net web site creates a list of files in the bin folder such as &#8220;pagex.cdc]]></description>
<content:encoded><![CDATA[<p>Pre-compiling an ASP.Net web site creates a list of files in the bin folder such as "pagex.cdcab7d2.compiled". I was wondering what "cdcab7d2" means and if it is a version dependent extention. </p>
<p>The following article from MSDN explains that </p>
<blockquote><p>the hex number within the file name (here <tt>cdcab7d2</tt>) is a hash code that represents the directory that the original file was in. So all files at the root of your source app will use <tt>cdcab7d2</tt>, while files in other folders will use different numbers. This is used to avoid naming conflicts in case you have files with the same name in different directories (which is very common for default.aspx!).</p>
</blockquote>
<p>Source: <a title="http://msdn.microsoft.com/en-us/library/aa479318.aspx" href="http://msdn.microsoft.com/en-us/library/aa479318.aspx">http://msdn.microsoft.com/en-us/library/aa479318.aspx</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Pre-compile web application by VS 2008]]></title>
<link>http://amiraryani.wordpress.com/2008/10/13/pre-compile-web-application-by-vs-2008/</link>
<pubDate>Mon, 13 Oct 2008 00:21:29 +0000</pubDate>
<dc:creator>amiraryani</dc:creator>
<guid>http://amiraryani.ar.wordpress.com/2008/10/13/pre-compile-web-application-by-vs-2008/</guid>
<description><![CDATA[If you create a WEBSITE by visual studio 2008 you get the option to publish it. This option also has]]></description>
<content:encoded><![CDATA[<p>If you create a WEBSITE by visual studio 2008 you get the option to publish it. This option also has a feature to pre-compile all aspx pages which is very useful. It makes the web site running faster (for the first time) and protect the source code. </p>
<p>If you create a WEB APPLICATION there is no such a option, you can only build the project and all the aspx files will be open to changed with no protection, also the web site will be slow on the first run. The answer to this problem is the Web Deployment add-on for Visual Studio. This add-on let you to add a new type of project to your web site solution which provide lots of customizations on the build process including pre-compile the web site.</p>
<p>Download Visual Studio® 2008 Web Deployment Projects - RTW from:<br /><a title="http://www.microsoft.com/downloads/details.aspx?familyid=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&#38;displaylang=en" href="http://www.microsoft.com/downloads/details.aspx?familyid=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&#38;displaylang=en">http://www.microsoft.com/downloads/details.aspx?familyid=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&#38;displaylang=en</a> </p>
<p>Scott Guthrie had a nice simple tutorial for this add-on on his blog: <br /><a title="http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx" href="http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx">http://weblogs.asp.net/scottgu/archive/2005/11/06/429723.aspx</a> </p>
<p>And this is the screen shot of the property page for Web Deployment add-on project, where I can define I do not want the aspx pages to be update able, i.e., pre-compile them to binary code: </p>
<p><a href="http://amiraryani.files.wordpress.com/2008/10/image1.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="289" alt="image" src="http://amiraryani.files.wordpress.com/2008/10/image-thumb1.png" width="488"/></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Encrypt ASP.net Database Password]]></title>
<link>http://kishur.wordpress.com/?p=160</link>
<pubDate>Sun, 12 Oct 2008 19:31:43 +0000</pubDate>
<dc:creator>kishur</dc:creator>
<guid>http://kishur.ar.wordpress.com/2008/10/13/encrypt-aspnet-database-password/</guid>
<description><![CDATA[When connecting the ASP.net with a database. You will need to configure its database connection in t]]></description>
<content:encoded><![CDATA[<p>When connecting the ASP.net with a database. You will need to configure its database connection in the web.config file.</p>
<p>However exposing the sensitiive data like the password and user name in the web config file can bring big damage to your system when it being seen by unauthorized user.</p>
<p>In the ASP.net 2.0 this problem can solve by adding an encryption method. This encryption can be applied by normal without any programming background. To do this you will need the aspnet_regiis.exe a built in framework tool provided by Microsoft.</p>
<p>Steps:</p>
<p>1. Open a windows command prompt.</p>
<p>2. Find and locate the aspnet_regiss.exe framework directory. The version number depends on the Microsoft.Net version in use.</p>
<p>Example : C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727</p>
<p>3. Once you have located the aspnet_regiis.exe. Run the command as below:</p>
<p>aspnet_regiis -pe <strong><em>"connectionStrings"</em> </strong>-app <strong><em>"/TestSite"</em> </strong>-prov <strong><em>"DataProtectionConfigurationProvider"</em></strong></p>
<p><span style="text-decoration:underline;"><strong>Where:</strong></span></p>
<p><strong>connectionStrings</strong> : -Element section need to be encrypted in the web.config file.</p>
<p><strong>/TestSite</strong> : - For example purpose I'm using /TestSite as the virtual directory. Please change to your virtual site.</p>
<p><strong>DataProtectionConfigurationProvider : </strong>- This is protection/encryption method selected. So far there are two method. DataProtectionConfigurationProvider &#38; <strong>RSAProtectedConfigurationProvider</strong>. For this example I'm running the DataProtectionConfigurationProvider. You may go for the RSAProtectionConfigurationProvider method when you are running a <strong>web farm</strong>.</p>
<p>4. Open the web.config file. Depends on the element selected above. The system will encrypt this section in the configuration file.</p>
<p><strong>Before Encryption</strong>:</p>
<p><a href="http://kishur.files.wordpress.com/2008/10/encryptbefore2.jpg"><img class="alignnone size-large wp-image-169" title="encryptbefore" src="http://kishur.wordpress.com/files/2008/10/encryptbefore2.jpg?w=450" alt="" width="450" height="191" /></a></p>
<p><strong>After Encryption:</strong></p>
<p><a href="http://kishur.files.wordpress.com/2008/10/encryptafter3.jpg"><img class="alignnone size-large wp-image-170" title="encryptafter" src="http://kishur.wordpress.com/files/2008/10/encryptafter3.jpg?w=450" alt="" width="450" height="208" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Page Response time code in ASP.Net:]]></title>
<link>http://epuri.wordpress.com/2008/10/12/page-response-time-code-in-aspnetp/</link>
<pubDate>Sun, 12 Oct 2008 18:16:51 +0000</pubDate>
<dc:creator>Epuri</dc:creator>
<guid>http://epuri.ar.wordpress.com/2008/10/12/page-response-time-code-in-aspnetp/</guid>
<description><![CDATA[Page Response time code in ASP.Net:
Place the below code in Global.asax file and run any .aspx page ]]></description>
<content:encoded><![CDATA[<h3>Page Response time code in ASP.Net:</h3>
<p>Place the below code in Global.asax file and run any .aspx page from the web site and then check for the result at footer of the page.</p>
<p><code><br />
DateTime timeReq;<br />
protected void Application_OnBeginRequest()<br />
{<br />
timeReq = DateTime.Now;<br />
}</code></p>
<p><code> </code></p>
<p><code>protected void Application_OnEndRequest()<br />
{<br />
TimeSpan diffTime = DateTime.Now - timeReq;</code></p>
<p><code>Response.Write("&#60;hr/&#62;This page was served at: " + DateTime.Now.ToString() + " in " + System.Math.Round(diffTime.TotalMilliseconds,2).ToString() + " milli seconds");</code></p>
<p><code>}</p>
<p></code></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[HttpServerUtility object in ASP.Net]]></title>
<link>http://epuri.wordpress.com/2008/10/12/in-aspnet-httpserverutility-object-is-p/</link>
<pubDate>Sun, 12 Oct 2008 08:13:40 +0000</pubDate>
<dc:creator>Epuri</dc:creator>
<guid>http://epuri.ar.wordpress.com/2008/10/12/httpserverutility-object-in-aspnet/</guid>
<description><![CDATA[In ASP.Net HttpServerUtility object is provided through the Page.Server property.
Advantages wtih Ht]]></description>
<content:encoded><![CDATA[<p>In ASP.Net HttpServerUtility object is provided through the Page.Server property.</p>
<p><strong>Advantages wtih HttpServerUtility.Transfer() or Page.Server.Transfer():</strong><br />
It doesn't involves the browser for redirection. Instead of sending a redirect message back to browser, ASP.Net  simply starts processing new page. This saves a bit of time.</p>
<p><strong>Limitations with Transfer():</strong><br />
It can't send the user to another website or to a non-ASP.Net page(ex: HTML page). It also won't change the URL in browser even server processes new page in background. This may cause problem to support browser bookmarks.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Code Nuggets: A Side-effect of Using DropDownList AppendDataBoundItems With Databound Items]]></title>
<link>http://uxuf.wordpress.com/2008/10/12/code-nuggets-a-side-effect-of-using-dropdownlist-appenddatabounditems/</link>
<pubDate>Sat, 11 Oct 2008 22:37:25 +0000</pubDate>
<dc:creator>uXuf</dc:creator>
<guid>http://uxuf.ar.wordpress.com/2008/10/12/code-nuggets-a-side-effect-of-using-dropdownlist-appenddatabounditems/</guid>
<description><![CDATA[Picture this: You have a webform with two DropDownLists, both of them are databound to some data you]]></description>
<content:encoded><![CDATA[<p>Picture this: You have a webform with two <code>DropDownList</code>s, both of them are databound to some data you get from a database. Now the first DropDownList's selection determines the contents of the second dropdown. So you simply do a AutoPostBack = true for the first dropdown and populate the second dropdown in the handler function. Right?</p>
<p>But wait. What if you are required to put in a static item in the dropdown? Something like <strong>"-- Please Select --"</strong> as the first item in the list to force the user to make a conscious choice. Hmmm, so you look around and find the nice little property named AppendDataBoundItems that will take care of that. All you have to do is declare the first (static) item in the Items collection in the designer (or put a &#60;asp:ListItem&#62; tag inside your &#60;asp:DropDownList&#62; tags) and set AppendDataBoundItems to true. This nice little property tells the DropDownList to add the databound items after the statically declared items, so you can have your happy little "-- Please Select --" in your dropdown.</p>
<h4>The Side-effect:</h4>
<p>The side-effect becomes evident when you play around with your two dropdowns. Its immediately clear that something is not quite right. The AppendDataBoundItems property forces your dropdown's items from the <em>previous </em>postback to be treated as static objects on<em>this</em> display. Sort of where you get an ever-growing second dropdown with a hangover from the postback, which is clearly not what you wanted in the first place!
<p><a href="http://uxuf.blogspot.com/2008/10/code-nuggets-side-effect-of-using.html">Continue Reading &#62;&#62;</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Unrecognized tag prefix or device filter 'asp']]></title>
<link>http://leason.wordpress.com/?p=5</link>
<pubDate>Sat, 11 Oct 2008 16:31:43 +0000</pubDate>
<dc:creator>tarunkotia</dc:creator>
<guid>http://leason.ar.wordpress.com/2008/10/11/unrecognized-tag-prefix-or-device-filter-asp/</guid>
<description><![CDATA[This is one of the most frustrating errors which I have encountered. I could not figure out the issu]]></description>
<content:encoded><![CDATA[<p>This is one of the most frustrating errors which I have encountered. I could not figure out the issue on my on. I did some google search for this error and found that if you are using master page in the website you need to keep that master page open. Need a fix for this issue soon.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Senior Project]]></title>
<link>http://admod.wordpress.com/?p=65</link>
<pubDate>Sat, 11 Oct 2008 11:44:23 +0000</pubDate>
<dc:creator>AdmOd</dc:creator>
<guid>http://admod.ar.wordpress.com/2008/10/11/senior-project/</guid>
<description><![CDATA[ยังอยู่ในช่วงการทำจุลนิพนธ์(อีกแล้]]></description>
<content:encoded><![CDATA[<p>ยังอยู่ในช่วงการทำจุลนิพนธ์(อีกแล้ว)<span class="zemanta-img zemanta-action-dragged" style="display:block;float:right;margin:1em;"><a href="http://en.wikipedia.org/wiki/Image:Aptana.png"><img style="border:medium none;display:block;" title="Aptana studio" src="http://upload.wikimedia.org/wikipedia/en/f/ff/Aptana.png" alt="Aptana studio" width="55" height="55" /></a></span></p>
<p>ไม่อยากจะเรียกว่า Final Project ถึงใครๆจะชอบเรียกมันว่าอย่างนั้น แต่ที่จริงแล้วควรจะเป็น Begin Project ซะมากกว่า เพราะยังไงๆมันก็เป็นแค่โปรเจคแรกที่จะได้ทำอย่างเป็นการเป็นงานสักที</p>
<p>สำหรับตอนนี้ขอบเขตงานแล้วก็ตัวงานเริ่มเข้าที่เข้าทางแล้ว เลยถึงเวลาที่จะต้องเลือกว่าจะพัฒนาด้วยอะไร<br />
เท่าที่คิดไว้ก็มี</p>
<ul>
<li>PHP<br />
แต่ยังหา <a class="zem_slink" title="Framework (office suite)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Framework_%28office_suite%29">Framework</a> ที่ถูกใจไม่ได้</li>
<li>ROR<br />
จะดีเหรอ? แต่ก็เริ่มเล่นกับ <a class="zem_slink" title="Aptana" rel="homepage" href="http://www.aptana.com">Aptana</a> ไปบ้างแล้ว ...มั่วแต่เล่น แต่ยังไม่ได้เริ่มจริงสักที (ลบ/สร้าง Project ไปหลายสิบที)</li>
<li>ASP .Net<br />
ถ้าจับด้วยตัวนี้คงไปได้เร็วเพราะเคยเรียนมาแล้ว แต่ไม่ค่อยชอบตัว Visual สักเท่าไหร่ มันดู....นู๊ปๆ</li>
</ul>
<p><span class="zemanta-img zemanta-action-dragged" style="display:block;float:right;margin:1em;"><a href="http://en.wikipedia.org/wiki/Image:Webkit_Logo.png"><img class="alignleft" style="border:medium none;display:block;" title="WebKit" src="http://upload.wikimedia.org/wikipedia/en/thumb/5/5a/Webkit_Logo.png/202px-Webkit_Logo.png" alt="WebKit" width="151" height="122" /></a></span>อันนี้สำหรับโปรแกรมฝั่ง Server ส่วนโปรแกรมฝั่งลูกอีกตัวคิดไว้แล้วว่าจะต้องเป็น .Net C# เพราะไปได้ Source ไว้เชื่อมกับ <a class="zem_slink" title="Global Positioning System" rel="wikipedia" href="http://en.wikipedia.org/wiki/Global_Positioning_System">GPS</a> (เรียกได้ว่าขี้เกียจ เลยก๊อปเขามา)</p>
<p>ยังเหลือโปรแกรมฝั่งลูกอีกตัว กำลังดูๆว่าจะทำเองเลยดีไหม ก็เลยอยุ่ในขั้นทดลอง กำลังรวบรวมโปรแกรมเลยมองๆ <a class="zem_slink" title="WebKit" rel="homepage" href="http://webkit.org">WebKit</a> ไว้ลองเล่นดูถ้าไม่ถูกใจยังไงอาจเปลี่ยนอีกที</p>
<p>สรุปแล้วงานก็ยังไม่เดินเท่าที่ควร เพราะอยากลอง Ruby เดี๋ยวเริ่มจริงๆจังๆไปสักนิดดูก่อนว่าใช้งานได้ไหม ถ้าไม่ได้ยังไงจะได้เปลี่ยนใจทัน</p>
<p>...ฟังเพลงต่อดีกว่า</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[ ASP.NET, ASP.NET AJAX, jQuery, IIS Tutorial]]></title>
<link>http://littletalk.wordpress.com/?p=352</link>
<pubDate>Sat, 11 Oct 2008 09:26:56 +0000</pubDate>
<dc:creator>ken zheng</dc:creator>
<guid>http://littletalk.ar.wordpress.com/2008/10/11/aspnet-aspnet-ajax-jquery-iis-tutorial/</guid>
<description><![CDATA[Scoot Gu has blogged a list of links to these technoloies. Check it now and refresh your knowledge
h]]></description>
<content:encoded><![CDATA[<p>Scoot Gu has blogged a list of links to these technoloies. Check it now and refresh your knowledge<br />
<a href="http://weblogs.asp.net/scottgu/archive/2008/10/10/october-10th-links-asp-net-asp-net-ajax-jquery-iis.aspx">http://weblogs.asp.net/scottgu/archive/2008/10/10/october-10th-links-asp-net-asp-net-ajax-jquery-iis.aspx</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Login Authenticate]]></title>
<link>http://datou.wordpress.com/?p=29</link>
<pubDate>Fri, 10 Oct 2008 18:38:50 +0000</pubDate>
<dc:creator>Datou</dc:creator>
<guid>http://datou.ar.wordpress.com/?p=29</guid>
<description><![CDATA[
&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; CodeFile=&quot;Login.aspx.cs]]></description>
<content:encoded><![CDATA[<p>[sourcecode language='html']<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Admin_Login" %></p>
<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></p>
<p><html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head id="Head1" runat="server"><br />
    <title>未命名頁面</title><br />
</head><br />
<body></p>
<form id="form1" runat="server">
<div>
        <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate" CssClass="CodePlexPanel" PasswordLabelText="密碼" UserNameLabelText="使用者名稱" BackColor="#F7F7DE" BorderColor="#CCCC99" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt" ><br />
            <TitleTextStyle CssClass="CodePlexPanelHeaderGreen" BackColor="#6B696B" Font-Bold="True" ForeColor="#FFFFFF" /><br />
        </asp:Login>
    </div>
</p></form>
<p></body><br />
</html>[/sourcecode]</p>
<p>[sourcecode language='csharp']using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Collections;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Web.UI.HtmlControls;<br />
using System.Data.SqlClient;<br />
using System.Text;</p>
<p>public partial class Admin_Login : System.Web.UI.Page<br />
{<br />
    String strCon = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        String ReturnUrl = Request.QueryString["ReturnUrl"];<br />
        if (ReturnUrl != null) {<br />
            if (Page.User.Identity.IsAuthenticated)<br />
                Response.Redirect("../.." + ReturnUrl);<br />
        }<br />
    }</p>
<p>    //驗證用戶<br />
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)<br />
    {<br />
        String strMD5 = FormsAuthentication.HashPasswordForStoringInConfigFile(Login1.Password.ToString(), "MD5");<br />
        try<br />
        {<br />
            if (ChkLogin(Login1.UserName, strMD5))<br />
            {<br />
                FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);<br />
                Server.Transfer("~/Admin/Default.aspx");<br />
                //Response.Write("<script>alert('UserName: " + Login1.UserName + " & Password: " + Login1.Password + "')</script>");<br />
            }<br />
        }<br />
        catch(Exception ex)<br />
        {<br />
            Response.Write("<script>alert('Error: " + ex.ToString() + "')</script>");<br />
        }<br />
    }</p>
<p>    //檢查登入帳號、密碼是否存在<br />
    public Boolean ChkLogin(String UserName, String UserPassword)<br />
    {<br />
        SqlConnection objCon = new SqlConnection(strCon);<br />
        SqlCommand objCmd = new SqlCommand();<br />
        SqlParameter pmtUserName = new SqlParameter();<br />
        SqlParameter pmtUserPassword = new SqlParameter();<br />
        String strSql;<br />
        SqlDataReader objReader;</p>
<p>        try<br />
        {<br />
            objCon.Open();</p>
<p>            strSql = "SELECT * FROM Users WHERE Account = @UserName AND Password = @Passwd";<br />
            objCmd.Connection = objCon;<br />
            objCmd.CommandText = strSql;</p>
<p>            pmtUserName.ParameterName = "@UserName";<br />
            pmtUserName.Value = UserName;<br />
            pmtUserPassword.ParameterName = "@Passwd";<br />
            pmtUserPassword.Value = UserPassword;<br />
            objCmd.Parameters.Add(pmtUserName);<br />
            objCmd.Parameters.Add(pmtUserPassword);<br />
            objReader = objCmd.ExecuteReader();</p>
<p>            if (objReader.Read())<br />
                return true;<br />
            else<br />
                return false;<br />
        }<br />
        catch<br />
        {<br />
            return false;<br />
        }<br />
        finally<br />
        {<br />
            pmtUserName = null;<br />
            pmtUserPassword = null;<br />
            objCmd.Clone();<br />
            objCon.Close();<br />
        }<br />
    }</p>
<p>    //將傳入值轉成 MD5 碼<br />
    public string GetMD5(string str)<br />
    {<br />
        byte[] md5In = System.Text.Encoding.UTF8.GetBytes(str);<br />
        System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();<br />
        byte[] md5Out = md5.ComputeHash(md5In);</p>
<p>        StringBuilder sb = new StringBuilder();<br />
        for (int i = 0; i < md5Out.Length; i++)<br />
        {<br />
            sb.Append(md5Out[i].ToString("x2"));<br />
        }<br />
        return sb.ToString();<br />
    }<br />
}[/sourcecode]</p>
<p>參考資料：<br />
<a href="http://blog.blueshop.com.tw/topcat/archive/2005/12/19/15562.aspx">topcat姍舞之間的極度凝聚</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Como enlazar los datos de un DataReader a un GridView]]></title>
<link>http://tecnosomnia.wordpress.com/?p=33</link>
<pubDate>Sat, 11 Oct 2008 02:15:15 +0000</pubDate>
<dc:creator>tecnosomnia</dc:creator>
<guid>http://tecnosomnia.ar.wordpress.com/2008/10/10/como-enlazar-los-datos-de-un-datareader-a-un-gridview/</guid>
<description><![CDATA[Esto puede parecer muy sencillo, pero la verdad es algo oscuro para alguien acostumbrado a utilizar ]]></description>
<content:encoded><![CDATA[<p>Esto puede parecer muy sencillo, pero la verdad es algo oscuro para alguien acostumbrado a utilizar solo el editor WYSIWYG del Visual Studio 2005.<br />
Básicamente el problema es que cuando queremos enlazar dinámicamente un GridView a una datasource generado en tiempo de ejecución (como por ejemplo un DataReader), el control no nos permite asignar columnas y estilos visuales automáticamente.<br />
Lo que tenemos que hacer es entrar al modo codigo HTML de la página ASPX, encontrar los bloques de código en donde se define el GridView y agregar cada uno de los campos de nuestro datasource a cada uno de las columnas del control:</p>
<p>asp:GridView ID="grid2" runat="server" AutoGenerateColumns="False"<br />
Columns<br />
asp:BoundField DataField="Columna_1" HeaderText="Columna 1" SortExpression="Columna 1"<br />
asp:ImageField HeaderText="foto" DataImageUrlField="foto"<br />
asp:ImageField<br />
Columns<br />
asp:GridView</p>
<p>Nota: eliminamos los simbolos para abrir y cerrar etiquetas de ASP (&#60;&#62;) para poder agregar el código.<br />
De esta manera podemos especificar un DataReader como fuente para nuestro control GridView y llenarlo dinamicamente en tiempo de ejecucion igualando cada uno de los campos de la base de datos del DataReader con los DataFields que especificamos.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Como dar formato a columnas de un GridView]]></title>
<link>http://tecnosomnia.wordpress.com/?p=30</link>
<pubDate>Sat, 11 Oct 2008 01:12:27 +0000</pubDate>
<dc:creator>tecnosomnia</dc:creator>
<guid>http://tecnosomnia.ar.wordpress.com/2008/10/10/como-dar-formato-a-columnas-de-un-gridview/</guid>
<description><![CDATA[Siguiendo con el tema de los GridViews de ASP.NET ahora vamos a ver como le podemos dar formato a di]]></description>
<content:encoded><![CDATA[<p>Siguiendo con el tema de los GridViews de ASP.NET ahora vamos a ver como le podemos dar formato a diferentes campos del grid desde el código HTML.<br />
Esto es muy útil cuando queremos traer desde nuestra base de datos números o fechas y queremos que se vean diferentes en nuestra aplicación.<br />
Por ejemplo yo tengo una columna en mi tabla de tipo DATE, sin embargo el Grid agregaba la hora a todas las fechas que desplegaba. De igual manera tengo una columna tipo DECIMAL que necesitaba del símbolo $.<br />
Después de pelearme un buen rato con el GUI para darle formato a mis columnas, descubrí dos cosas importantes:</p>
<ul>
<li>Es más fácil hacer este tipo de modificaciones en el código HTML de la página en la que estamos trabajando.</li>
<li>Hay cosas muy escondidas de cada uno de los controles de ASP.NET.</li>
</ul>
<p>El caso es que para lograr lo que necesitamos tenemos que hacer lo siguiente dentro del archivo ASPX de la página dentro de las declaraciones de columnas:</p>
<ul>
<li>Para columnas tipo DATE: asp:BoundField DataField="Fecha Registro" HeaderText="Fecha Registro" SortExpression="Fecha Registro" dataformatstring="{0:dd/MM/yy}" htmlencode="False".</li>
</ul>
<p>Con esto logramos que la fecha sólo contenga realmente la fecha sin agregar la hora (la tenga el campo o no). Además la formateamos como dia/mes/año (que es como se usa en Español).<br />
El formato que necesitamos también se puede agregar en el GUI seleccionando "Editar Columnas" y poniendo la expresión regular en el renglón DataFormatString, sin embargo lo que nadie nos dice es que tenemos que ajustar la opción HtmlEncode a "off" para que esto funcione.</p>
<ul>
<li>Para columnas de tipo numérico podemos usar lo siguiente: asp:BoundField DataField="precio" HeaderText="Precio" SortExpression="precio" DataFormatString="{0:$#,#.00}" HtmlEncode="False".</li>
</ul>
<p>Lo que produce una columna de precio en donde vemos los números con el formato correcto para pesos y centavos.</p>
<p>Estos dos ejemplos utilizan las expresiones regulares para dar formato a los campos. Este tipo de expresiones son muy utilizadas tanto en programación como en otras cosas en donde queremos dar formato a cadenas de caracteres (por ejemplo en Excel). Para los que quieran leer mas al respecto les dejo los siguientes links: <a href="http://en.wikipedia.org/wiki/Regular_expression">Regular Expresion</a> y <a href="http://www.regular-expressions.info/">Regular-Expressions.info</a></p>
<p>Espero que les sirva!</p>
<p>P.D. recuerden que tengo que eliminar los "&#60; /&#62;" de los tags HTML.</p>
]]></content:encoded>
</item>

</channel>
</rss>
