<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-11256636</id><updated>2026-07-23T23:04:08.460-07:00</updated><title type='text'>Shivam.Net</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>32</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-11256636.post-5171879158359123371</id><published>2007-08-24T09:05:00.000-07:00</published><updated>2007-08-30T06:15:18.139-07:00</updated><title type='text'>CLR has been unable to transition from COM context for 60 seconds</title><content type='html'>this problem was bugging me, and this blog provided me solution for it.&lt;br /&gt;&lt;br /&gt;http://wpfwonderland.wordpress.com/2007/08/16&lt;br /&gt;/clr-has-been-unable-to-transition-from-com-context-for-60-seconds/&lt;br /&gt;&lt;br /&gt;Cheers</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/5171879158359123371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/5171879158359123371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/5171879158359123371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/5171879158359123371'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2007/08/clr-has-been-unable-to-transition-from.html' title='CLR has been unable to transition from COM context for 60 seconds'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-116834229224554120</id><published>2007-01-09T03:30:00.000-08:00</published><updated>2007-01-09T03:31:32.560-08:00</updated><title type='text'>SOAP Exception, with trace or without</title><content type='html'>When a Web service returns a SOAP Exception, you could decide on whether to pass on the trace or not.&lt;br /&gt;If the web service consumer could be indicated with the trace, so as to help in fixing the problem then pass on the trace.&lt;br /&gt;Or when business layer validations are thrown as exception all you need is &quot;Server was unable to process --&gt; User name is invalid&quot;, instead of the lengthy SOAP exception.&lt;br /&gt;To enable exception, with trace, Web.config of web service, set the customErrors mode to &quot;RemoteOnly&quot; or &quot;Off&quot;&lt;br /&gt;To disable trace in the exception, Web.config of web service, set the customErrors mode to &quot;On&quot;&lt;br /&gt;&lt;br /&gt;Cheers</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/116834229224554120/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/116834229224554120' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116834229224554120'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116834229224554120'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2007/01/soap-exception-with-trace-or-without.html' title='SOAP Exception, with trace or without'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-116194409569328929</id><published>2006-10-27T03:13:00.000-07:00</published><updated>2006-10-27T03:14:56.570-07:00</updated><title type='text'>Class doesn&#39;t support automation</title><content type='html'>Annoying problem - Class doesn&#39;t support automation: JScript Error&lt;br /&gt;Every time I browse the Internet with IE, had to live up with this error, was really annoying.&lt;br /&gt;As usual was not on the top of priority so didnt look into that as an issue.&lt;br /&gt;Today I thought this is the day, lets put an end to it. Looked for help on Net using gooooogle and ended up with &lt;br /&gt;http://www.techgroup21.com/sub2page.asp?sub2navID=19&lt;br /&gt;followed the steps mentioned, except the step with WScript.exe, as it was already there.&lt;br /&gt;And got rid of it :-)</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/116194409569328929/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/116194409569328929' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116194409569328929'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116194409569328929'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/10/class-doesnt-support-automation.html' title='Class doesn&#39;t support automation'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-116135383255340746</id><published>2006-10-20T07:14:00.000-07:00</published><updated>2006-10-20T07:19:21.436-07:00</updated><title type='text'>Form Authentication Login Page</title><content type='html'>Using MS VisualStudio.Net 2005, developing an ASP.Net web application with forms authentication [VS.Net builtin web server], then look further.&lt;br /&gt;Wonder why the login page images / style sheets are not loaded in forms &lt;br /&gt;authentication. &lt;br /&gt;This is because the built in webserver passes all request through ASP.Net.&lt;br /&gt;For futher details http://weblogs.asp.net/scottgu/archive/2006/01/31/437027.aspx</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/116135383255340746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/116135383255340746' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116135383255340746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/116135383255340746'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/10/form-authentication-login-page.html' title='Form Authentication Login Page'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-114915943463635658</id><published>2006-06-01T03:55:00.000-07:00</published><updated>2006-06-01T04:09:55.963-07:00</updated><title type='text'>IgnoreSectionHandler</title><content type='html'>When you add custom configurations in application config, then you will have to provide configuration handlers in config sections, when you dont want to handle them seperately, instead plan to read the xml and get values use&lt;br /&gt;&lt;br /&gt;Add section with type of System.Configuration.IgnoreSectionHandler, System for the custom config that you want to ignore&lt;br /&gt;&lt;br /&gt;this would prevent the system from throwing exception</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/114915943463635658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/114915943463635658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114915943463635658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114915943463635658'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/06/ignoresectionhandler.html' title='IgnoreSectionHandler'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-114865562725397150</id><published>2006-05-26T07:57:00.000-07:00</published><updated>2006-05-26T08:01:54.966-07:00</updated><title type='text'>Batch Build - VS.Net 2003</title><content type='html'>Batch build option is available in VS.Net 2005 [Solution with C# projects], that allows you to build for all configuration. User could select multiple project and various build configuration.&lt;br /&gt;&lt;br /&gt;But &quot;Batch Build&quot; option would not be available even if one VB.Net project is added to the solution.</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/114865562725397150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/114865562725397150' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114865562725397150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114865562725397150'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/05/batch-build-vsnet-2003.html' title='Batch Build - VS.Net 2003'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-114865483454733259</id><published>2006-05-26T07:47:00.000-07:00</published><updated>2006-05-26T07:47:14.796-07:00</updated><title type='text'>System Tray Application</title><content type='html'>Trying to do a system tray application,&lt;br /&gt;&lt;br /&gt;points to note:&lt;br /&gt;1) ShowInTaskbar property of the window should be set to false&lt;br /&gt;2) on Form_Load function call the hide function&lt;br /&gt;3) Add NotifyIcon object&lt;br /&gt;3) Add ContextMenu, and menu event handlers&lt;br /&gt;4) Set the contextmenu object to NotifyIcon&#39;s contextmenu</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/114865483454733259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/114865483454733259' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114865483454733259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114865483454733259'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/05/system-tray-application.html' title='System Tray Application'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-114831380026592651</id><published>2006-05-22T08:59:00.000-07:00</published><updated>2006-05-22T09:04:28.583-07:00</updated><title type='text'>HttpRuntime - Max request length</title><content type='html'>When using Input type file and trying to upload huge files, returns an error &quot;Maximum request length exceeded&quot; or page not available error, thats because the ASP.Net max request length is set to 4 megs.&lt;br /&gt;&lt;br /&gt;Incase you want to upload bigger files, then config has to be changed.&lt;br /&gt;&lt;br /&gt;&lt;httpRuntime maxRequestLength=&quot;102400&quot;&gt; to be added in web.config [this would accept till 100 megs]&lt;br /&gt;&lt;br /&gt;for further info refer http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/114831380026592651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/114831380026592651' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114831380026592651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114831380026592651'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/05/httpruntime-max-request-length.html' title='HttpRuntime - Max request length'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-114683774939888569</id><published>2006-05-05T07:01:00.000-07:00</published><updated>2006-05-05T07:02:29.813-07:00</updated><title type='text'>Difference between Build Solution and Rebuild Solution option in VS.Net</title><content type='html'>Source of information : http://dotnetjunkies.com/WebLog/nilapenn/archive/2004/05/22/14251.aspx&lt;br /&gt;&lt;br /&gt;VisualStudio.Net provides us with two options for compiling and creating builds for our application. They are Build Solution and Rebuild Solution options which can be accessed from the Build menu. The differences between these two options are&lt;br /&gt;&lt;br /&gt;1. The Build Solution option compiles only those project files and components that have changed since the last build. For example consider that you have two projects Proj1 and Proj2 in your solution MySolution. When you compile the solution using Build Solution option after making some changes to Proj1 only Proj1 will be compiled and built but Proj2 will not be compiled since there are no changes to it.&lt;br /&gt;&lt;br /&gt;2. On the other hand the Rebuild Solution option builds all project files and components irrespective of the changes made to them.  For example consider that you have two projects Proj1 and Proj2 in your solution MySolution. When you compile the solution using Rebuild Solution option after making some changes to Proj1, both Proj1 and Proj2 will be compiled and built even though there are no changes made to Proj2.</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/114683774939888569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/114683774939888569' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114683774939888569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/114683774939888569'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2006/05/difference-between-build-solution-and.html' title='Difference between Build Solution and Rebuild Solution option in VS.Net'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-113406414669431138</id><published>2005-12-08T09:41:00.000-08:00</published><updated>2005-12-08T09:49:06.726-08:00</updated><title type='text'>Setting Name for controls created using Javascript</title><content type='html'>when you create input controls dynamically using javascript like&lt;br /&gt;var inputValue = document.createElement(&#39;input&#39;);&lt;br /&gt;and try to set the id using &lt;br /&gt;inputValue.setAttribute(&#39;id&#39;, &#39;controlName&#39;); &lt;br /&gt;works fine, creates and control added is &amp;lt;input id=controlName&amp;gt;&lt;br /&gt;but when you try to set the name attribute, does not reflect in the control, reason being IE does not allow you to change the name of the control, after it is created.&lt;br /&gt;Work around for this is&lt;br /&gt;var inputValue = document.createElement(&#39;&amp;lt;input name=&quot;controlName&quot;&amp;gt;&#39;);&lt;br /&gt;this would create the control with the name element.&lt;br /&gt;&lt;br /&gt;If asked why should you go for this work around, in postback when you try to use Request.Form to read the dynamically created controls, would work only if the name attribute is added.</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/113406414669431138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/113406414669431138' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/113406414669431138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/113406414669431138'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/12/setting-name-for-controls-created.html' title='Setting Name for controls created using Javascript'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-113049653916803337</id><published>2005-10-28T03:47:00.000-07:00</published><updated>2005-10-28T08:39:04.556-07:00</updated><title type='text'>Creating Server Controls</title><content type='html'>must see this page&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondevelopingwebformscontrols.asp&quot; target=&quot;_blank&quot;&gt; MSDN Microsoft&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/113049653916803337/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/113049653916803337' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/113049653916803337'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/113049653916803337'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/10/creating-server-controls.html' title='Creating Server Controls'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112564702703585778</id><published>2005-09-02T00:40:00.000-07:00</published><updated>2005-09-02T00:47:31.583-07:00</updated><title type='text'>Set values for password control</title><content type='html'>When trying to set value for asp:textbox control with textmode password, using textboxname.Text, still loads blank textbox control.&lt;br /&gt;To get the server control of password type with value use the following code instead&lt;br /&gt;textboxname.Attributes(&quot;value&quot;) =  &quot;password&quot;</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112564702703585778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112564702703585778' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112564702703585778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112564702703585778'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/09/set-values-for-password-control.html' title='Set values for password control'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547750366124841</id><published>2005-08-31T01:25:00.000-07:00</published><updated>2005-08-31T01:58:04.530-07:00</updated><title type='text'>Accessing user controls from code behind</title><content type='html'>You&amp;nbsp;could&amp;nbsp;access&amp;nbsp;user&amp;nbsp;controls&amp;nbsp;from&amp;nbsp;code&amp;nbsp;behind&amp;nbsp;to&amp;nbsp;add&amp;nbsp;dynamic&amp;nbsp;controls&lt;br /&gt;&lt;br /&gt;Add&amp;nbsp;a&amp;nbsp;place&amp;nbsp;holder&amp;nbsp;in&amp;nbsp;user&amp;nbsp;control,&amp;nbsp;and&amp;nbsp;make&amp;nbsp;it&amp;nbsp;public&amp;nbsp;in&amp;nbsp;code-behind&lt;br /&gt;&lt;br /&gt;In&amp;nbsp;application&amp;nbsp;pages,&amp;nbsp;code-behind&amp;nbsp;declare&amp;nbsp;an&amp;nbsp;object&amp;nbsp;of&amp;nbsp;type&amp;nbsp;user&amp;nbsp;control&lt;br /&gt;&lt;br /&gt;&#39;&amp;nbsp;user&amp;nbsp;control&amp;nbsp;used&amp;nbsp;to&amp;nbsp;add&amp;nbsp;links&lt;br /&gt;Dim&amp;nbsp;pageMyControl&amp;nbsp;As&amp;nbsp;MyUserControl&amp;nbsp;&lt;br /&gt;Dim&amp;nbsp;lnkNewLink&amp;nbsp;As&amp;nbsp;WebControls.LinkButton&lt;br /&gt;Dim&amp;nbsp;newLinkButtonIndex&amp;nbsp;as&amp;nbsp;Int32&lt;br /&gt;&#39;&amp;nbsp;get&amp;nbsp;the&amp;nbsp;user&amp;nbsp;control&lt;br /&gt;pageMyControl&amp;nbsp;=&amp;nbsp;DirectCast(FindControl(&quot;ucMyControl&quot;),&amp;nbsp;MyUserControl)&amp;nbsp;&lt;br /&gt;If&amp;nbsp;Not&amp;nbsp;pageMyControl&amp;nbsp;Is&amp;nbsp;Nothing&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;lnkNewLink&amp;nbsp;=&amp;nbsp;New&amp;nbsp;WebControls.LinkButton&lt;br /&gt;&amp;nbsp;&amp;nbsp;lnkNewLink.Text&amp;nbsp;=&amp;nbsp;&quot;&amp;nbsp;[NewLink]&amp;nbsp;&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;lnkNewLink.ID&amp;nbsp;=&amp;nbsp;&quot;lnkNewLink&quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;lnkNewLink.CausesValidation&amp;nbsp;=&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;Add&amp;nbsp;event&amp;nbsp;handler&amp;nbsp;to&amp;nbsp;the&amp;nbsp;link&amp;nbsp;button,&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;this&amp;nbsp;function&amp;nbsp;has&amp;nbsp;to&amp;nbsp;be&amp;nbsp;written&amp;nbsp;in&amp;nbsp;page&amp;nbsp;code-behind&lt;br /&gt;&amp;nbsp;&amp;nbsp;AddHandler&amp;nbsp;lnkNewLink.Click,&amp;nbsp;AddressOf&amp;nbsp;ControlNewLink&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;Add&amp;nbsp;the&amp;nbsp;link&amp;nbsp;button&amp;nbsp;to&amp;nbsp;user&amp;nbsp;control&lt;br /&gt;&amp;nbsp;&amp;nbsp;pageMyControl.phLinks.Controls.Add(lnkNewLink)&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;if&amp;nbsp;incase&amp;nbsp;you&amp;nbsp;want&amp;nbsp;to&amp;nbsp;show/hide&amp;nbsp;the&amp;nbsp;link&amp;nbsp;button&amp;nbsp;based&amp;nbsp;on&amp;nbsp;certain&amp;nbsp;condition&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;or&amp;nbsp;change&amp;nbsp;properties&amp;nbsp;of&amp;nbsp;the&amp;nbsp;link&amp;nbsp;button&amp;nbsp;based&amp;nbsp;on&amp;nbsp;codition,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;the&amp;nbsp;index&amp;nbsp;is&amp;nbsp;required&lt;br /&gt;&amp;nbsp;&amp;nbsp;newLinkButtonIndex&amp;nbsp;=&amp;nbsp;pageMyControl.phLinks.Controls.IndexOf(lnkNewLink)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&#39;&amp;nbsp;heres&amp;nbsp;an&amp;nbsp;example&amp;nbsp;to&amp;nbsp;set&amp;nbsp;visible&amp;nbsp;property&amp;nbsp;to&amp;nbsp;false&lt;br /&gt;&amp;nbsp;&amp;nbsp;pageMyControl.phLinks.Controls(newLinkButtonIndex).Visible&amp;nbsp;=&amp;nbsp;False&lt;br /&gt;End&amp;nbsp;If</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547750366124841/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547750366124841' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547750366124841'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547750366124841'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/accessing-user-controls-from-code.html' title='Accessing user controls from code behind'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547648409584947</id><published>2005-08-31T01:18:00.000-07:00</published><updated>2005-08-31T01:21:24.110-07:00</updated><title type='text'>Custom text box</title><content type='html'>Custom text box with required field validator, regular expression validators&lt;br /&gt;&lt;br /&gt;Imports System.ComponentModel&lt;br /&gt;Imports System.Web.UI&lt;br /&gt;Imports System.Web.UI.WebControls&lt;br /&gt;&lt;br /&gt;&amp;lt;DefaultProperty(&quot;Text&quot;), ToolboxData(&quot;&amp;lt;{0}:TextBox runat=server&amp;gt;&amp;lt;/{0}:TextBox&amp;gt;&quot;)&amp;gt; _&lt;br /&gt;Public Class TextBox&lt;br /&gt;  Inherits System.Web.UI.WebControls.TextBox&lt;br /&gt;&lt;br /&gt;#Region &quot;Private/Public/Shared variables&quot;&lt;br /&gt;  &#39; private variables&lt;br /&gt;  Private _text As String = String.Empty&lt;br /&gt;&lt;br /&gt;  &#39; reg ex validator properties&lt;br /&gt;  Private _textType As ENums.TextType&lt;br /&gt;  Private _typeText As String = String.Empty&lt;br /&gt;  Private _typeDisplay As ValidatorDisplay = ValidatorDisplay.None&lt;br /&gt;  Private _typeVisible As Boolean = True&lt;br /&gt;  Private _typeEnabled As Boolean = True&lt;br /&gt;  Private _typeEnableClientScript As Boolean = True&lt;br /&gt;  Private _typeEnableViewState As Boolean&lt;br /&gt;  Private _typeCssClass As String = String.Empty&lt;br /&gt;  Private _typeErrorMessage As String = &quot; Is Invalid&quot;&lt;br /&gt;  Private _typeSpecialChars As String = String.Empty&lt;br /&gt;&lt;br /&gt;  &#39;required field validator properties&lt;br /&gt;  Private _isRequired As Boolean&lt;br /&gt;  Private _requiredErrorMessage As String = &quot; Is Required&quot;&lt;br /&gt;  Private _requiredText As String = &quot; *&quot;&lt;br /&gt;  Private _requiredDisplay As ValidatorDisplay = ValidatorDisplay.Static&lt;br /&gt;  Private _requiredVisible As Boolean = True&lt;br /&gt;  Private _requiredEnabled As Boolean = True&lt;br /&gt;  Private _requiredEnableClientScript As Boolean = True&lt;br /&gt;  Private _requiredEnableViewState As Boolean&lt;br /&gt;  Private _requiredCssClass As String = String.Empty&lt;br /&gt;  Private _requiredShowTextAlways As Boolean = True&lt;br /&gt;&lt;br /&gt;  &#39; private controls&lt;br /&gt;  Private requiredValidate As RequiredFieldValidator&lt;br /&gt;  Private regExpValidate As RegularExpressionValidator&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Properties&quot;&lt;br /&gt;&lt;br /&gt;#Region &quot;Property Overrides&quot;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Appearance&quot;), DefaultValue(&quot;&quot;)&amp;gt; _&lt;br /&gt;  Public Overrides Property [Text]() As String&lt;br /&gt;    Get&lt;br /&gt;      Return _text&lt;br /&gt;    End Get&lt;br /&gt;&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      _text = Value&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Custom properties&quot;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot; Is Required&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredErrorMessage() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredErrorMessage&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredErrorMessage&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredErrorMessage&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredErrorMessage&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredErrorMessage = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredErrorMessage&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.ErrorMessage = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredErrorMessage = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredErrorMessage&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Property IsRequired() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;IsRequired&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;IsRequired&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _isRequired&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _isRequired&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _isRequired = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;IsRequired&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Value Then&lt;br /&gt;          If requiredValidate Is Nothing Then&lt;br /&gt;            requiredValidate = New RequiredFieldValidator&lt;br /&gt;            requiredValidate.ControlToValidate = Me.ClientID&lt;br /&gt;            requiredValidate.Display = _requiredDisplay&lt;br /&gt;            requiredValidate.ErrorMessage = RequiredErrorMessage&lt;br /&gt;            requiredValidate.Text = _requiredText&lt;br /&gt;            requiredValidate.EnableClientScript = _requiredEnableClientScript&lt;br /&gt;            requiredValidate.Enabled = _requiredEnabled&lt;br /&gt;            requiredValidate.Visible = _requiredVisible&lt;br /&gt;            requiredValidate.EnableViewState = _requiredEnableViewState&lt;br /&gt;            requiredValidate.CssClass = _requiredCssClass&lt;br /&gt;            Me.Controls.Add(requiredValidate)&lt;br /&gt;          End If&lt;br /&gt;        Else&lt;br /&gt;          If Not requiredValidate Is Nothing Then&lt;br /&gt;            Me.Controls.Remove(requiredValidate)&lt;br /&gt;            requiredValidate = Nothing&lt;br /&gt;          End If&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _isRequired = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;IsRequired&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot; *&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredText() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredText&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredText&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredText&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredText&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredText = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredText&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Text = _requiredText&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredText = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredText&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredShowTextAlways() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredShowTextAlways&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredShowTextAlways&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredShowTextAlways&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredShowTextAlways&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredShowTextAlways = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredShowTextAlways&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredShowTextAlways = True&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredShowTextAlways&quot;) = True&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(ValidatorDisplay.Static)&amp;gt; _&lt;br /&gt;  Public Property RequiredDisplay() As ValidatorDisplay&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredDisplay&quot;) Is Nothing Then&lt;br /&gt;          Return CType(ViewState(&quot;RequiredDisplay&quot;), ValidatorDisplay)&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredDisplay&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredDisplay&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As ValidatorDisplay)&lt;br /&gt;      Try&lt;br /&gt;        _requiredDisplay = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredDisplay&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Display = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredDisplay = ValidatorDisplay.None&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredDisplay&quot;) = ValidatorDisplay.None&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredVisible() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredVisible&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredVisible&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredVisible&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredVisible&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredVisible = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredVisible&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Visible = _requiredVisible&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredVisible = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredVisible&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnabled() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnabled&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnabled&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnabled&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnabled&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnabled = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnabled&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Enabled = _requiredEnabled&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnabled = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnabled&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnableClientScript() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnableClientScript&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnableClientScript&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnableClientScript&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnableClientScript = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableClientScript&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.EnableClientScript = _requiredEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnableClientScript = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableClientScript&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnableViewState() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnableViewState&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnableViewState&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnableViewState&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnableViewState = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableViewState&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.EnableViewState = _requiredEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnableViewState = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableViewState&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot;&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredCSSClass() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredCssClass&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredCssClass&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredCssClass&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredCssClass&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredCssClass = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredCssClass&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.CssClass = _requiredCssClass&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredCssClass = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredCssClass&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(ValidatorDisplay.Static)&amp;gt; _&lt;br /&gt;  Public Property TypeDisplay() As ValidatorDisplay&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeDisplay&quot;) Is Nothing Then&lt;br /&gt;          Return CType(ViewState(&quot;TypeDisplay&quot;), ValidatorDisplay)&lt;br /&gt;        Else&lt;br /&gt;          Return _typeDisplay&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeDisplay&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As ValidatorDisplay)&lt;br /&gt;      Try&lt;br /&gt;        _typeDisplay = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeDisplay&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.Display = _typeDisplay&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeDisplay = ValidatorDisplay.None&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeDisplay&quot;) = ValidatorDisplay.None&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property TypeVisible() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeVisible&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;TypeVisible&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeVisible&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeVisible&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _typeVisible = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeVisible&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.Visible = _typeVisible&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeVisible = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeVisible&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property TypeEnabled() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeEnabled&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;TypeEnabled&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeEnabled&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeEnabled&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _typeEnabled = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnabled&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.Enabled = _typeEnabled&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeEnabled = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnabled&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property TypeEnableClientScript() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeEnableClientScript&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;TypeEnableClientScript&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeEnableClientScript&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _typeEnableClientScript = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnableClientScript&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.EnableClientScript = _typeEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeEnableClientScript = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnableClientScript&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Property TypeEnableViewState() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeEnableViewState&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;TypeEnableViewState&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeEnableViewState&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _typeEnableViewState = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnableViewState&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.EnableViewState = _typeEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeEnableViewState = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeEnableViewState&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot;&quot;)&amp;gt; _&lt;br /&gt;  Public Property TypeCssClass() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeCssClass&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;TypeCssClass&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeCssClass&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeCssClass&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _typeCssClass = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeCssClass&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.CssClass = _typeCssClass&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeCssClass = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeCssClass&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot;&quot;)&amp;gt; _&lt;br /&gt;  Public Property TypeSpecialChars() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeSpecialChars&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;TypeSpecialChars&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeSpecialChars&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeSpecialChars&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _typeSpecialChars = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeSpecialChars&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          If _textType = ENums.TextType.AlphanumericSpecialChars Then&lt;br /&gt;            regExpValidate.ValidationExpression = &quot;[a-zA-Z0-9&quot; &amp;&amp;amp;nbsp;_typeSpecialChars &amp;&amp;amp;nbsp;&quot;]*&quot;&lt;br /&gt;          End If&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeSpecialChars = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeSpecialChars&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot; Is Invalid&quot;)&amp;gt; _&lt;br /&gt;  Public Property TypeErrorMessage() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TypeErrorMessage&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;TypeErrorMessage&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _typeErrorMessage&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _typeErrorMessage&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _typeErrorMessage = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeErrorMessage&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not regExpValidate Is Nothing Then&lt;br /&gt;          regExpValidate.ErrorMessage = _typeErrorMessage&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _typeErrorMessage = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TypeErrorMessage&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(ENums.TextType.All)&amp;gt; _&lt;br /&gt;  Public Property TextType() As ENums.TextType&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;TextType&quot;) Is Nothing Then&lt;br /&gt;          Return CType(ViewState(&quot;TextType&quot;), ENums.TextType)&lt;br /&gt;        Else&lt;br /&gt;          Return _textType&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _textType&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As ENums.TextType)&lt;br /&gt;      Try&lt;br /&gt;        _textType = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TextType&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        SetRegEx(Value)&lt;br /&gt;      Catch&lt;br /&gt;        _textType = ENums.TextType.All&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;TextType&quot;) = ENums.TextType.All&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Methods/Functions/Sub&quot;&lt;br /&gt;  Private Sub SetRegEx(ByVal Value As ENums.TextType)&lt;br /&gt;    If Value &amp;lt;&amp;gt; ENums.TextType.All Then&lt;br /&gt;      If regExpValidate Is Nothing Then&lt;br /&gt;        regExpValidate = New RegularExpressionValidator&lt;br /&gt;        regExpValidate.ControlToValidate = Me.ClientID&lt;br /&gt;        Me.Controls.Add(regExpValidate)&lt;br /&gt;      End If&lt;br /&gt;      regExpValidate.CssClass = _typeCssClass&lt;br /&gt;      regExpValidate.Display = _typeDisplay&lt;br /&gt;      regExpValidate.EnableClientScript = _typeEnableClientScript&lt;br /&gt;      regExpValidate.Enabled = _typeEnabled&lt;br /&gt;      regExpValidate.EnableViewState = _typeEnableViewState&lt;br /&gt;      regExpValidate.ErrorMessage = _typeErrorMessage&lt;br /&gt;      regExpValidate.Text = _typeText&lt;br /&gt;&lt;br /&gt;      Select Case Value&lt;br /&gt;        Case ENums.TextType.Alphabhets&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;[a-zA-Z]*&quot;&lt;br /&gt;        Case ENums.TextType.Alphanumeric&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;[a-zA-Z0-9]*&quot;&lt;br /&gt;        Case ENums.TextType.AlphanumericSpecialChars&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;[a-zA-Z0-9&quot; &amp;&amp;amp;nbsp;_typeSpecialChars &amp;&amp;amp;nbsp;&quot;]*&quot;&lt;br /&gt;        Case ENums.TextType.Decimals&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;\d*\.{0,1}\d+&quot;&lt;br /&gt;        Case ENums.TextType.Email&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*&quot;&lt;br /&gt;        Case ENums.TextType.Numeric&lt;br /&gt;          regExpValidate.ValidationExpression = &quot;\d*&quot;&lt;br /&gt;        Case Else&lt;br /&gt;          Me.Controls.Remove(regExpValidate)&lt;br /&gt;          regExpValidate = Nothing&lt;br /&gt;      End Select&lt;br /&gt;    Else&lt;br /&gt;      If Not regExpValidate Is Nothing Then&lt;br /&gt;        Me.Controls.Remove(regExpValidate)&lt;br /&gt;        regExpValidate = Nothing&lt;br /&gt;      End If&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Overrides&quot;&lt;br /&gt;  Protected Overrides Sub OnInit(ByVal e As EventArgs)&lt;br /&gt;    MyBase.OnInit(e)&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)&lt;br /&gt;    If Me.ReadOnly Then&lt;br /&gt;      _isRequired = False&lt;br /&gt;      _textType = ENums.TextType.All&lt;br /&gt;      If Not requiredValidate Is Nothing Then&lt;br /&gt;        Me.Controls.Remove(requiredValidate)&lt;br /&gt;        requiredValidate = Nothing&lt;br /&gt;      End If&lt;br /&gt;      If Not regExpValidate Is Nothing Then&lt;br /&gt;        Me.Controls.Remove(regExpValidate)&lt;br /&gt;        regExpValidate = Nothing&lt;br /&gt;      End If&lt;br /&gt;      &#39; to make it look like a label&lt;br /&gt;      Me.BorderWidth = WebControls.Unit.Pixel(0)&lt;br /&gt;      MyBase.Render(output)&lt;br /&gt;      &#39;output.Write(&quot;&amp;lt;span id=&quot;&quot;&quot; &amp;&amp;amp;nbsp;Me.ClientID &amp;&amp;amp;nbsp;&quot;&quot;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;Me.Text &amp;&amp;amp;nbsp;&quot;&amp;lt;/span&amp;gt;&quot;)&lt;br /&gt;    Else&lt;br /&gt;      MyBase.Render(output)&lt;br /&gt;      If Not requiredValidate Is Nothing Then&lt;br /&gt;        If Me._requiredShowTextAlways Then&lt;br /&gt;          If Me._requiredCssClass.Length &amp;gt; 0 Then&lt;br /&gt;            output.Write(HtmlTextWriter.SpaceChar)&lt;br /&gt;            output.Write(&quot;&amp;lt;span class=&quot;&quot;&quot; &amp;&amp;amp;nbsp;Me._requiredCssClass &amp;&amp;amp;nbsp;&quot;&quot;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;Me._requiredText &amp;&amp;amp;nbsp;&quot;&amp;lt;/span&amp;gt;&quot;)&lt;br /&gt;          Else&lt;br /&gt;            output.Write(HtmlTextWriter.SpaceChar)&lt;br /&gt;            output.Write(&quot;&amp;lt;span style=&quot;&quot;color:Red&quot;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;Me._requiredText &amp;&amp;amp;nbsp;&quot;&amp;lt;/span&amp;gt;&quot;)&lt;br /&gt;          End If&lt;br /&gt;          requiredValidate.Text = String.Empty&lt;br /&gt;          requiredValidate.Display = ValidatorDisplay.None&lt;br /&gt;        End If&lt;br /&gt;        If String.Compare(requiredValidate.ControlToValidate, String.Empty, False) = 0 Then&lt;br /&gt;          requiredValidate.ControlToValidate = Me.ClientID&lt;br /&gt;        End If&lt;br /&gt;        requiredValidate.RenderControl(output)&lt;br /&gt;      End If&lt;br /&gt;      If Not regExpValidate Is Nothing Then&lt;br /&gt;        If String.Compare(regExpValidate.ControlToValidate, String.Empty, False) = 0 Then&lt;br /&gt;          regExpValidate.ControlToValidate = Me.ClientID&lt;br /&gt;        End If&lt;br /&gt;        regExpValidate.RenderControl(output)&lt;br /&gt;      End If&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)&lt;br /&gt;    MyBase.AddAttributesToRender(writer)&lt;br /&gt;    &#39; this is added to trim values in text areas to max length&lt;br /&gt;    If Me.MaxLength &amp;gt; 0 And Me.TextMode = TextBoxMode.MultiLine Then&lt;br /&gt;      writer.AddAttribute(&quot;onblur&quot;, _&lt;br /&gt;         &quot;this.value = this.value.slice(0,&quot; &amp;&amp;amp;nbsp;Me.MaxLength &amp;&amp;amp;nbsp;&quot;);&quot;)&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub LoadViewState(ByVal savedState As Object)&lt;br /&gt;    If Not savedState Is Nothing Then&lt;br /&gt;      MyBase.LoadViewState(savedState)&lt;br /&gt;      Me.IsRequired = Me.IsRequired&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;End Class&lt;br /&gt;&lt;br /&gt;Public Class ENums&lt;br /&gt;  Public Enum TextType&lt;br /&gt;    All&lt;br /&gt;    Alphabhets&lt;br /&gt;    Alphanumeric&lt;br /&gt;    AlphanumericSpecialChars&lt;br /&gt;    Numeric&lt;br /&gt;    Decimals&lt;br /&gt;    Email&lt;br /&gt;  End Enum&lt;br /&gt;End Class</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547648409584947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547648409584947' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547648409584947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547648409584947'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/custom-text-box.html' title='Custom text box'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547613255224614</id><published>2005-08-31T01:06:00.000-07:00</published><updated>2005-08-31T01:15:32.560-07:00</updated><title type='text'>Custom drop down list</title><content type='html'>Drop down box that has autocomplete option&lt;br /&gt;&lt;br /&gt;Imports System.ComponentModel&lt;br /&gt;Imports System.Web.UI&lt;br /&gt;Imports System.Web.UI.WebControls&lt;br /&gt;Imports System.Text&lt;br /&gt;&lt;br /&gt;&amp;lt;DefaultProperty(&quot;DataSource&quot;), ToolboxData(&quot;&amp;lt;{0}:DropDownList runat=server&amp;gt;&amp;lt;/{0}:DropDownList&amp;gt;&quot;)&amp;gt; _&lt;br /&gt;Public Class DropDownList&lt;br /&gt;    Inherits System.Web.UI.WebControls.DropDownList&lt;br /&gt;&lt;br /&gt;#Region &quot;Private/Shared variables&quot;&lt;br /&gt;  &#39;required field validator properties&lt;br /&gt;  Private _isRequired As Boolean&lt;br /&gt;  Private _requiredErrorMessage As String = &quot; Is Required&quot;&lt;br /&gt;  Private _requiredText As String = &quot; *&quot;&lt;br /&gt;  Private _requiredDisplay As ValidatorDisplay = ValidatorDisplay.Static&lt;br /&gt;  Private _requiredVisible As Boolean = True&lt;br /&gt;  Private _requiredEnabled As Boolean = True&lt;br /&gt;  Private _requiredEnableClientScript As Boolean = True&lt;br /&gt;  Private _requiredEnableViewState As Boolean&lt;br /&gt;  Private _requiredCssClass As String = String.Empty&lt;br /&gt;  Private _requiredShowTextAlways As Boolean = True&lt;br /&gt;&lt;br /&gt;  &#39; private controls&lt;br /&gt;  Private requiredValidate As RequiredFieldValidator&lt;br /&gt;&lt;br /&gt;  &#39; private variables for key press function&lt;br /&gt;  Private Shared functionName As String = &quot;DropDownList_onkeypress&quot;&lt;br /&gt;  Private _caseSensitiveKey As Boolean = False&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Properties&quot;&lt;br /&gt;&lt;br /&gt;#Region &quot;Property overrides&quot;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;KeyPress&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Overridable Property CaseSensitiveKey() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;CaseSensitiveKey&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;CaseSensitiveKey&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _caseSensitiveKey&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _caseSensitiveKey&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      _caseSensitiveKey = Value&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        ViewState(&quot;CaseSensitiveKey&quot;) = Value&lt;br /&gt;      End If&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Custom properties&quot;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot; Is Required&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredErrorMessage() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredErrorMessage&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredErrorMessage&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredErrorMessage&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredErrorMessage&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredErrorMessage = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredErrorMessage&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.ErrorMessage = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredErrorMessage = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredErrorMessage&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Property IsRequired() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;IsRequired&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;IsRequired&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _isRequired&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _isRequired&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _isRequired = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;IsRequired&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Value Then&lt;br /&gt;          If requiredValidate Is Nothing Then&lt;br /&gt;            requiredValidate = New RequiredFieldValidator&lt;br /&gt;            requiredValidate.ControlToValidate = Me.UniqueID&lt;br /&gt;            requiredValidate.Display = _requiredDisplay&lt;br /&gt;            requiredValidate.ErrorMessage = RequiredErrorMessage&lt;br /&gt;            requiredValidate.Text = _requiredText&lt;br /&gt;            requiredValidate.EnableClientScript = _requiredEnableClientScript&lt;br /&gt;            requiredValidate.Enabled = _requiredEnabled&lt;br /&gt;            requiredValidate.Visible = _requiredVisible&lt;br /&gt;            requiredValidate.EnableViewState = _requiredEnableViewState&lt;br /&gt;            requiredValidate.CssClass = _requiredCssClass&lt;br /&gt;            Me.Controls.Add(requiredValidate)&lt;br /&gt;          End If&lt;br /&gt;        Else&lt;br /&gt;          If Not requiredValidate Is Nothing Then&lt;br /&gt;            Me.Controls.Remove(requiredValidate)&lt;br /&gt;            requiredValidate = Nothing&lt;br /&gt;          End If&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _isRequired = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;IsRequired&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot; *&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredText() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredText&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredText&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredText&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredText&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredText = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredText&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Text = _requiredText&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredText = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredText&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredShowTextAlways() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredShowTextAlways&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredShowTextAlways&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredShowTextAlways&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredShowTextAlways&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredShowTextAlways = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredShowTextAlways&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredShowTextAlways = True&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredShowTextAlways&quot;) = True&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(ValidatorDisplay.Static)&amp;gt; _&lt;br /&gt;  Public Property RequiredDisplay() As ValidatorDisplay&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredDisplay&quot;) Is Nothing Then&lt;br /&gt;          Return CType(ViewState(&quot;RequiredDisplay&quot;), ValidatorDisplay)&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredDisplay&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredDisplay&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As ValidatorDisplay)&lt;br /&gt;      Try&lt;br /&gt;        _requiredDisplay = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredDisplay&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Display = Value&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredDisplay = ValidatorDisplay.None&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredDisplay&quot;) = ValidatorDisplay.None&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredVisible() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredVisible&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredVisible&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredVisible&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredVisible&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredVisible = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredVisible&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Visible = _requiredVisible&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredVisible = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredVisible&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnabled() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnabled&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnabled&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnabled&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnabled&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnabled = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnabled&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.Enabled = _requiredEnabled&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnabled = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnabled&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(True)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnableClientScript() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnableClientScript&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnableClientScript&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnableClientScript&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnableClientScript = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableClientScript&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.EnableClientScript = _requiredEnableClientScript&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnableClientScript = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableClientScript&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(False)&amp;gt; _&lt;br /&gt;  Public Property RequiredEnableViewState() As Boolean&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredEnableViewState&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToBoolean(ViewState(&quot;RequiredEnableViewState&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredEnableViewState&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As Boolean)&lt;br /&gt;      Try&lt;br /&gt;        _requiredEnableViewState = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableViewState&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.EnableViewState = _requiredEnableViewState&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredEnableViewState = False&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredEnableViewState&quot;) = False&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;&lt;br /&gt;  &amp;lt;Bindable(True), Category(&quot;Validate&quot;), DefaultValue(&quot;&quot;)&amp;gt; _&lt;br /&gt;  Public Property RequiredCSSClass() As String&lt;br /&gt;    Get&lt;br /&gt;      If Me.EnableViewState Then&lt;br /&gt;        If Not ViewState(&quot;RequiredCssClass&quot;) Is Nothing Then&lt;br /&gt;          Return Convert.ToString(ViewState(&quot;RequiredCssClass&quot;))&lt;br /&gt;        Else&lt;br /&gt;          Return _requiredCssClass&lt;br /&gt;        End If&lt;br /&gt;      Else&lt;br /&gt;        Return _requiredCssClass&lt;br /&gt;      End If&lt;br /&gt;    End Get&lt;br /&gt;    Set(ByVal Value As String)&lt;br /&gt;      Try&lt;br /&gt;        _requiredCssClass = Value&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredCssClass&quot;) = Value&lt;br /&gt;        End If&lt;br /&gt;        If Not requiredValidate Is Nothing Then&lt;br /&gt;          requiredValidate.CssClass = _requiredCssClass&lt;br /&gt;        End If&lt;br /&gt;      Catch&lt;br /&gt;        _requiredCssClass = String.Empty&lt;br /&gt;        If Me.EnableViewState Then&lt;br /&gt;          ViewState(&quot;RequiredCssClass&quot;) = String.Empty&lt;br /&gt;        End If&lt;br /&gt;      End Try&lt;br /&gt;    End Set&lt;br /&gt;  End Property&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;#Region &quot;Overrides&quot;&lt;br /&gt;  Protected Overrides Sub Render(ByVal output As System.Web.UI.HtmlTextWriter)&lt;br /&gt;    If Not Me.Enabled Then&lt;br /&gt;      Me.BorderWidth = WebControls.Unit.Pixel(0)&lt;br /&gt;    End If&lt;br /&gt;    MyBase.Render(output)&lt;br /&gt;    If Not requiredValidate Is Nothing Then&lt;br /&gt;      If Me._requiredShowTextAlways Then&lt;br /&gt;        If Me._requiredCssClass.Length &amp;gt; 0 Then&lt;br /&gt;          output.Write(HtmlTextWriter.SpaceChar)&lt;br /&gt;          output.Write(&quot;&amp;lt;span class=&quot;&quot;&quot; &amp;&amp;amp;nbsp;Me._requiredCssClass &amp;&amp;amp;nbsp;&quot;&quot;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;Me._requiredText &amp;&amp;amp;nbsp;&quot;&amp;lt;/span&amp;gt;&quot;)&lt;br /&gt;        Else&lt;br /&gt;          output.Write(HtmlTextWriter.SpaceChar)&lt;br /&gt;          output.Write(&quot;&amp;lt;span style=&quot;&quot;color:Red&quot;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;Me._requiredText &amp;&amp;amp;nbsp;&quot;&amp;lt;/span&amp;gt;&quot;)&lt;br /&gt;        End If&lt;br /&gt;        requiredValidate.Text = String.Empty&lt;br /&gt;        requiredValidate.Display = ValidatorDisplay.None&lt;br /&gt;      End If&lt;br /&gt;      requiredValidate.RenderControl(output)&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)&lt;br /&gt;    MyBase.OnLoad(e)    &#39; call the base class method&lt;br /&gt;    &#39; define the client-side script&lt;br /&gt;    Dim script As StringBuilder = New StringBuilder(500)&lt;br /&gt;    script.Append(&quot;&amp;lt;script language=&quot; &amp;&amp;amp;nbsp;Chr(34) &amp;&amp;amp;nbsp;&quot;javascript&quot; &amp;&amp;amp;nbsp;Chr(34) &amp;&amp;amp;nbsp;&quot; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;type=&quot; &amp;&amp;amp;nbsp;Chr(34) &amp;&amp;amp;nbsp;&quot;text/javascript&quot; &amp;&amp;amp;nbsp;Chr(34) &amp;&amp;amp;nbsp;&quot;&amp;gt;&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;function &quot; &amp;&amp;amp;nbsp;functionName &amp;&amp;amp;nbsp;&quot; (dropdownlist,caseSensitive) {&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  // check the keypressBuffer attribute is defined on the dropdownlist&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  var undefined; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  if (dropdownlist.keypressBuffer == undefined) { &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    dropdownlist.keypressBuffer = &#39;&#39;; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  } &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  // get the key that was pressed &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  var key = String.fromCharCode(window.event.keyCode); &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  dropdownlist.keypressBuffer += key;&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  if (!caseSensitive) {&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    // convert buffer to lowercase&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  }&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  // find if it is the start of any of the options &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  var optionsLength = dropdownlist.options.length; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  for (var n=0; n &amp;lt; optionsLength; n++) { &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    var optionText = dropdownlist.options[n].text; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    if (!caseSensitive) {&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;      optionText = optionText.toLowerCase();&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    }&quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) { &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;      dropdownlist.selectedIndex = n; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;      return false; // cancel the default behavior since &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;                    // we have selected our own value &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;    } &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  } &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  // reset initial key to be inline with default behavior &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  dropdownlist.keypressBuffer = key; &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;  return true; // give default behavior &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;} &quot; &amp;&amp;amp;nbsp;vbCrLf)&lt;br /&gt;    script.Append(&quot;&amp;lt;/script&amp;gt;&quot;)&lt;br /&gt;&lt;br /&gt;    &#39; register the client-side script block&lt;br /&gt;    Me.Page.RegisterClientScriptBlock(functionName, script.ToString())&lt;br /&gt;    &#39; add to the onkeypress event&lt;br /&gt;    Me.Attributes.Add(&quot;onkeypress&quot;, &quot;return &quot; + functionName + &quot;(this,&quot; + _caseSensitiveKey.ToString().ToLower() + &quot;)&quot;)&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;  Protected Overrides Function CreateControlCollection() As System.Web.UI.ControlCollection&lt;br /&gt;    Return New ControlCollection(Me)&lt;br /&gt;  End Function&lt;br /&gt;&lt;br /&gt;  Protected Overrides Sub LoadViewState(ByVal savedState As Object)&lt;br /&gt;    If Not savedState Is Nothing Then&lt;br /&gt;      MyBase.LoadViewState(savedState)&lt;br /&gt;      Me.IsRequired = Me.IsRequired&lt;br /&gt;    End If&lt;br /&gt;  End Sub&lt;br /&gt;&lt;br /&gt;#End Region&lt;br /&gt;&lt;br /&gt;End Class</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547613255224614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547613255224614' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547613255224614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547613255224614'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/custom-drop-down-list.html' title='Custom drop down list'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547536955994138</id><published>2005-08-31T00:59:00.000-07:00</published><updated>2005-08-31T02:06:10.993-07:00</updated><title type='text'>Send mail using SMTP</title><content type='html'>following&amp;nbsp;function&amp;nbsp;can&amp;nbsp;be&amp;nbsp;added&amp;nbsp;in&amp;nbsp;a&amp;nbsp;utility&amp;nbsp;class&amp;nbsp;and&amp;nbsp;&lt;br /&gt;can&amp;nbsp;be&amp;nbsp;called&amp;nbsp;from&amp;nbsp;the&amp;nbsp;application&amp;nbsp;with&amp;nbsp;parameters&amp;nbsp;to&amp;nbsp;send&amp;nbsp;email.&lt;br /&gt;&lt;br /&gt;SMTP&amp;nbsp;Server&amp;nbsp;IP&amp;nbsp;could&amp;nbsp;be&amp;nbsp;stored&amp;nbsp;in&amp;nbsp;web.config&amp;nbsp;or&amp;nbsp;database,&amp;nbsp;so&amp;nbsp;that&amp;nbsp;&lt;br /&gt;it&amp;nbsp;can&amp;nbsp;be&amp;nbsp;changed&amp;nbsp;easily.&lt;br /&gt;&lt;br /&gt;Imports&amp;nbsp;System.Web.Mail&amp;nbsp;&#39;&amp;nbsp;namespace&amp;nbsp;is&amp;nbsp;required&amp;nbsp;for&amp;nbsp;smtp&amp;nbsp;mail&lt;br /&gt;&lt;br /&gt;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;SendMail(ByVal&amp;nbsp;fromAddress&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;toAddress&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;ByVal&amp;nbsp;ccAddress&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;bccAddress&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;ByVal&amp;nbsp;msgSubject&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;msgBody&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;ByVal&amp;nbsp;smtpServer&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Optional&amp;nbsp;ByVal&amp;nbsp;msgPriority&amp;nbsp;As&amp;nbsp;Int32&amp;nbsp;=&amp;nbsp;0,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Optional&amp;nbsp;ByVal&amp;nbsp;msgFormat&amp;nbsp;As&amp;nbsp;Int32&amp;nbsp;=&amp;nbsp;0)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;Dim&amp;nbsp;mailMsg&amp;nbsp;As&amp;nbsp;MailMessage&lt;br /&gt;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailMsg&amp;nbsp;=&amp;nbsp;New&amp;nbsp;MailMessage&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailMsg.From&amp;nbsp;=&amp;nbsp;ConvertToString(fromAddress)&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailMsg.To&amp;nbsp;=&amp;nbsp;ConvertToString(toAddress)&lt;br /&gt;&amp;nbsp;&amp;nbsp;If&amp;nbsp;ConvertToString(ccAddress).Length&amp;nbsp;&gt;&amp;nbsp;0&amp;nbsp;Then&amp;nbsp;mailMsg.Cc&amp;nbsp;=&amp;nbsp;ccAddress&lt;br /&gt;&amp;nbsp;&amp;nbsp;If&amp;nbsp;ConvertToString(bccAddress).Length&amp;nbsp;&gt;&amp;nbsp;0&amp;nbsp;Then&amp;nbsp;mailMsg.Bcc&amp;nbsp;=&amp;nbsp;bccAddress&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailMsg.Subject&amp;nbsp;=&amp;nbsp;ConvertToString(msgSubject)&lt;br /&gt;&amp;nbsp;&amp;nbsp;mailMsg.Body&amp;nbsp;=&amp;nbsp;ConvertToString(msgBody)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;If&amp;nbsp;msgPriority&amp;nbsp;&lt;&amp;nbsp;priority&amp;nbsp;=&quot;&amp;nbsp;MailPriority.Low&quot;&gt;&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mailMsg.Priority&amp;nbsp;=&amp;nbsp;MailPriority.High&lt;br /&gt;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mailMsg.Priority&amp;nbsp;=&amp;nbsp;MailPriority.Normal&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;If&amp;nbsp;msgFormat&amp;nbsp;&gt;&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mailMsg.BodyFormat&amp;nbsp;=&amp;nbsp;MailFormat.Html&lt;br /&gt;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mailMsg.BodyFormat&amp;nbsp;=&amp;nbsp;MailFormat.Text&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;SmtpMail.SmtpServer&amp;nbsp;=&amp;nbsp;smtpServer&lt;br /&gt;&amp;nbsp;&amp;nbsp;SmtpMail.Send(mailMsg)&lt;br /&gt;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;True&lt;br /&gt;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;End&amp;nbsp;Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547536955994138/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547536955994138' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547536955994138'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547536955994138'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/send-mail-using-smtp.html' title='Send mail using SMTP'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547515960226255</id><published>2005-08-31T00:55:00.000-07:00</published><updated>2005-08-31T00:59:39.283-07:00</updated><title type='text'>String compare</title><content type='html'>Comparing strings using equal to operator is an overhead especially when you try to change case and compare, instead string.compare could be used. &lt;br /&gt;&lt;br /&gt;Here I used ConvertToString function mentioned earlier in the blog, so it could handle null values also.&lt;br /&gt;&lt;br /&gt;Function returns true, strings are same, else different&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;StringCompareNoCase(ByVal&amp;nbsp;object1&amp;nbsp;As&amp;nbsp;Object,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;object2&amp;nbsp;As&amp;nbsp;Object)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&amp;nbsp;string1&amp;nbsp;As&amp;nbsp;String&amp;nbsp;=&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&amp;nbsp;string2&amp;nbsp;As&amp;nbsp;String&amp;nbsp;=&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string1&amp;nbsp;=&amp;nbsp;ConvertToString(object1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string2&amp;nbsp;=&amp;nbsp;ConvertToString(object2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;String.Compare(string1,&amp;nbsp;string2,&amp;nbsp;True)&amp;nbsp;=&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;StringCompareNoCase(ByVal&amp;nbsp;string1&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;string2&amp;nbsp;As&amp;nbsp;String)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;String.Compare(string1,&amp;nbsp;string2,&amp;nbsp;True)&amp;nbsp;=&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;StringCompare(ByVal&amp;nbsp;object1&amp;nbsp;As&amp;nbsp;Object,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;object2&amp;nbsp;As&amp;nbsp;Object)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&amp;nbsp;string1&amp;nbsp;As&amp;nbsp;String&amp;nbsp;=&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&amp;nbsp;string2&amp;nbsp;As&amp;nbsp;String&amp;nbsp;=&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string1&amp;nbsp;=&amp;nbsp;ConvertToString(object1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string2&amp;nbsp;=&amp;nbsp;ConvertToString(object2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;String.Compare(string1,&amp;nbsp;string2,&amp;nbsp;False)&amp;nbsp;=&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;StringCompare(ByVal&amp;nbsp;string1&amp;nbsp;As&amp;nbsp;String,&amp;nbsp;_&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ByVal&amp;nbsp;string2&amp;nbsp;As&amp;nbsp;String)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;String.Compare(string1,&amp;nbsp;string2,&amp;nbsp;False)&amp;nbsp;=&amp;nbsp;0&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547515960226255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547515960226255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547515960226255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547515960226255'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/string-compare.html' title='String compare'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547490890613874</id><published>2005-08-31T00:54:00.000-07:00</published><updated>2005-08-31T00:55:08.906-07:00</updated><title type='text'>Convert to boolean handling NULL</title><content type='html'>&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToBoolean(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;Object)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToBoolean(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToBoolean(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;String)&amp;nbsp;As&amp;nbsp;Boolean&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToBoolean(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;False&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547490890613874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547490890613874' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547490890613874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547490890613874'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/convert-to-boolean-handling-null.html' title='Convert to boolean handling NULL'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547484807100676</id><published>2005-08-31T00:53:00.000-07:00</published><updated>2005-08-31T00:54:08.073-07:00</updated><title type='text'>Convert to Double handling NULL</title><content type='html'>&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToDouble(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;Object)&amp;nbsp;As&amp;nbsp;Double&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToDouble(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToDouble(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;String)&amp;nbsp;As&amp;nbsp;Double&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToDouble(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547484807100676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547484807100676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547484807100676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547484807100676'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/convert-to-double-handling-null.html' title='Convert to Double handling NULL'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547480667499253</id><published>2005-08-31T00:52:00.000-07:00</published><updated>2005-08-31T00:53:26.676-07:00</updated><title type='text'>Convert to Int32 handling NULL</title><content type='html'>Public Shared Function ConvertToInt32(ByVal value As Object) As Int32&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If (value Is Nothing) OrElse (value Is DBNull.Value) Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return Convert.ToInt32(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Try&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Public Shared Function ConvertToInt32(ByVal value As String) As Int32&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If (value Is Nothing) OrElse (value Is DBNull.Value) Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return Convert.ToInt32(value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Try&lt;br /&gt;End Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547480667499253/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547480667499253' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547480667499253'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547480667499253'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/convert-to-int32-handling-null.html' title='Convert to Int32 handling NULL'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112547471439961167</id><published>2005-08-31T00:44:00.000-07:00</published><updated>2005-08-31T00:51:54.406-07:00</updated><title type='text'>Convert to string handling NULL</title><content type='html'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToString(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;Object)&amp;nbsp;As&amp;nbsp;String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToString(value).Trim()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToString(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;Boolean)&amp;nbsp;As&amp;nbsp;String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToString(value).Trim()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Public&amp;nbsp;Shared&amp;nbsp;Function&amp;nbsp;ConvertToString(ByVal&amp;nbsp;value&amp;nbsp;As&amp;nbsp;String)&amp;nbsp;As&amp;nbsp;String&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;Nothing)&amp;nbsp;OrElse&amp;nbsp;(value&amp;nbsp;Is&amp;nbsp;DBNull.Value)&amp;nbsp;Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;Convert.ToString(value).Trim()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return&amp;nbsp;String.Empty&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End&amp;nbsp;Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112547471439961167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112547471439961167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547471439961167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112547471439961167'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/convert-to-string-handling-null.html' title='Convert to string handling NULL'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112495744202832601</id><published>2005-08-25T01:06:00.000-07:00</published><updated>2005-08-25T01:12:36.476-07:00</updated><title type='text'>Restricting windows close event - windows application</title><content type='html'>&lt;p&gt;Heres a sample to check if the user clicks on &#39;X&#39; in the right top of the window, instead of save and close button&lt;br /&gt;&lt;br /&gt;&#39; declare the variable in the form code behind&lt;br /&gt;Private confirmClose As Boolean&lt;br /&gt;&lt;br /&gt;Private Sub btnSaveAndClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveAndClose.Click&lt;br /&gt;     confirmClose = True&lt;br /&gt;     Me.Close()&lt;br /&gt;End Sub&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Private Sub DemoForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing&lt;br /&gt;  If Not confirmClose Then&lt;br /&gt;     &#39; means the he has not clicked on trial button, but X&lt;br /&gt;     e.Cancel = True&lt;br /&gt;    &#39; this will not allow the window to close&lt;br /&gt;    &#39; add msg box to show that user has to click of&lt;br /&gt;    &#39; save and close button, and cannot use &#39;X&#39; to close the application&lt;br /&gt;  End If&lt;br /&gt;End Sub&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112495744202832601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112495744202832601' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495744202832601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495744202832601'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/restricting-windows-close-event.html' title='Restricting windows close event - windows application'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112495665349120681</id><published>2005-08-25T00:53:00.000-07:00</published><updated>2005-08-25T01:11:33.876-07:00</updated><title type='text'>Relative path in user controls</title><content type='html'>use ~/ instead of your relative [../../] paths in user controls as they could be used by pages in different level folders&lt;br /&gt;&lt;br /&gt;~ indicates your app root folder&lt;br /&gt;so if the control is in /mycontrols/usercontrols&lt;br /&gt;u should use ~/mycontrols/usercontrols</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112495665349120681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112495665349120681' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495665349120681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495665349120681'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/relative-path-in-user-controls.html' title='Relative path in user controls'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112495536602653771</id><published>2005-08-25T00:28:00.000-07:00</published><updated>2005-08-25T03:46:18.633-07:00</updated><title type='text'>Finding duplicates using SQL</title><content type='html'>Heres a query that helps you find the duplicates and updates all duplicate records with error description as duplicate record leaving one record&lt;br /&gt;If the primary key id is a integer based identity column, if not create a temp table with same structure and additional identity column, and use the identity column instead of primary key id&lt;br /&gt;&lt;br /&gt;UPDATE TableName SET ErrorDescription = &#39;Duplicate record&#39; WHERE PrimaryKeyId &gt; (SELECT MIN(PrimaryKeyId) FROM TableName CheckDuplicate WHERE (CheckDuplicate.Code = TableName.Code OR CheckDuplicate.Name = TableName.Name)) AND ErrorDescription IS NULL&lt;br /&gt;&lt;br /&gt;If records were&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;PrimaryKeyId&lt;/td&gt;&lt;td&gt;Code&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;ErrorDescription&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;CD1&lt;/td&gt;&lt;td&gt;Name 1&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;CD2&lt;/td&gt;&lt;td&gt;Name 2&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;CD1&lt;/td&gt;&lt;td&gt;Name 3&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;CD4&lt;/td&gt;&lt;td&gt;Name 1&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;They become&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;PrimaryKeyId&lt;/td&gt;&lt;td&gt;Code&lt;/td&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;ErrorDescription&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;1&lt;/td&gt;&lt;td&gt;CD1&lt;/td&gt;&lt;td&gt;Name 1&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;2&lt;/td&gt;&lt;td&gt;CD2&lt;/td&gt;&lt;td&gt;Name 2&lt;/td&gt;&lt;td&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;3&lt;/td&gt;&lt;td&gt;CD1&lt;/td&gt;&lt;td&gt;Name 3&lt;/td&gt;&lt;td&gt;Duplicate record&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;4&lt;/td&gt;&lt;td&gt;CD4&lt;/td&gt;&lt;td&gt;Name 1&lt;/td&gt;&lt;td&gt;Duplicate record&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112495536602653771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112495536602653771' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495536602653771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495536602653771'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/finding-duplicates-using-sql.html' title='Finding duplicates using SQL'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-11256636.post-112495466184615883</id><published>2005-08-25T00:20:00.000-07:00</published><updated>2005-08-25T00:27:07.523-07:00</updated><title type='text'>URL Encode from class</title><content type='html'>Have you come across a situation, where you set the query parameters, but want to check for null values, and then URL encode the value, heres a function that can be added to a common utilities class that can be called from your application to URL Encode the value, if null empty string is returned. &lt;br /&gt;&lt;br /&gt;  &#39;&#39;&#39; -----------------------------------------------------------------------------&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;summary&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; URL Encode the object&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;/summary&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;param name=&quot;value&quot;&amp;gt;&amp;lt;/param&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;returns&gt;URL Encoded string&amp;gt;/returns&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;remarks&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;/remarks&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;history&amp;gt;&lt;br /&gt;  &#39;&#39;&#39;  [K. Gopi] 8/25/2005 Created&lt;br /&gt;  &#39;&#39;&#39; &amp;lt;/history&amp;gt;&lt;br /&gt;  &#39;&#39;&#39; -----------------------------------------------------------------------------&lt;br /&gt;  Public Shared Function URLEncode(ByVal value As Object) As String&lt;br /&gt;  &amp;nbsp;&amp;nbsp;Try&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;If (value Is Nothing) OrElse (value Is DBNull.Value) Then&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return String.Empty&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;Else&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Return Web.HttpUtility.UrlEncode(Convert.ToString(value))&lt;br /&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;br /&gt;   &amp;nbsp;&amp;nbsp;Catch&lt;br /&gt;   &amp;nbsp;&amp;nbsp;&amp;nbsp;Return String.Empty&lt;br /&gt;   &amp;nbsp;End Try&lt;br /&gt;  End Function</content><link rel='replies' type='application/atom+xml' href='http://shivamdotnet.blogspot.com/feeds/112495466184615883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/11256636/112495466184615883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495466184615883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/11256636/posts/default/112495466184615883'/><link rel='alternate' type='text/html' href='http://shivamdotnet.blogspot.com/2005/08/url-encode-from-class.html' title='URL Encode from class'/><author><name>K. Gopi</name><uri>http://www.blogger.com/profile/06598731250556885555</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>