<?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-8735280615943229552</id><updated>2024-09-08T05:00:49.090-07:00</updated><category term="c#"/><category term="asp.net"/><category term="load"/><category term="sharepoint"/><category term="string"/><category term="Active Directory"/><category term="Error"/><category term="Linq"/><category term="MoveNext()"/><category term="System.Linq.Enumerable.WhereListIterator"/><category term="Xdocumnet"/><category term="ajax"/><category term="binary"/><category term="control"/><category term="conversion"/><category term="current user"/><category term="currentuser"/><category term="custom"/><category term="file"/><category term="linq-to-xml"/><category term="log4net"/><category term="namespace"/><category term="parse"/><category term="section"/><category term="upload"/><category term="web.config"/><category term="windows"/><category term="xdocument"/><category term="xelement"/><category term="xml"/><category term="xmldocument"/><category term="xmlnamespace"/><title type='text'>ASP.NET</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-5794835600355921</id><published>2011-01-08T14:36:00.000-08:00</published><updated>2011-01-08T14:48:58.669-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="custom"/><category scheme="http://www.blogger.com/atom/ns#" term="section"/><category scheme="http://www.blogger.com/atom/ns#" term="sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="web.config"/><title type='text'>Creating Custom Sections and Encrypting the Section in web.config</title><content type='html'>&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Creating Custom Sections and Encryption in web.config&lt;/b&gt;&lt;br /&gt;
Web application development need different kind of customization,one of the common scenario is creation custom sections in web.config.For the ease of development .net framework supports different set of custom sections.There are mainly three kind custom section. &lt;br /&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;1. &lt;/i&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i&gt;SingleTagSectionHandler&lt;/i&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;/b&gt;&lt;br /&gt;
This will help to add a custom single xml tag to web.config. Define your custom section in &amp;lt; &lt;span style=&quot;color: #0b5394;&quot;&gt;configSections &amp;gt;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; configSections &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; section name=&quot;UserInfo&quot;&lt;br /&gt;
type=&quot;System.Configuration.NameValueSectionHandler&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt;/ configSections &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Add your custom single tag section. For example I would like keep a user credential information.(Below we will talk how to encrypt)&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt;&amp;nbsp;UserInfo UserName =&quot;Myuser&quot; Password =&quot;****&quot; Domain =&quot;MyDomain&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Read the data from code&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;(System.Collections.IDictionary) System.Configuration.ConfigurationSettings.GetConfig(&quot;UserInfo&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;2. &lt;/i&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i&gt;NameValueSectionHandler&lt;/i&gt;&lt;/b&gt; This will help you to keep key value pairs of data.It will be usefull to keep the data in custom section so you can define /name you section properly in web.config.&lt;br /&gt;
&lt;br /&gt;
For example going to create new section for supported extensions and supported special servers .&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Define a custom section group&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; section name =&quot;SupportedExtensions&quot;&lt;br /&gt;
type =&quot;System.Configuration.NameValueSectionHandler&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; section name =&quot;SupportedServer&quot;&lt;br /&gt;
type =&quot;System.Configuration.NameValueSectionHandler&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; SupportedExtensions &amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;Image&quot; value =&quot;.jpg,png&quot;/&amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;Video&quot; value =&quot;flv,wmv&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/ SupportedExtensions &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; SupportedServer &amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;AppServer&quot; value =&quot;server1,server2&quot;/&amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;ImageServer&quot; value =&quot;server4,server5&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/ SupportedServer &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Read the data from code&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;(System.Collections.NameValueCollection) System.Configuration.ConfigurationSettings.GetConfig(&quot;SupportedServer&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;3. &lt;/i&gt;&lt;/b&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i&gt;DictionarySectionHandler&lt;/i&gt;&lt;/b&gt; &lt;br /&gt;
This will help you to keep key value pairs of data in nested sections. It will be use full to keep the data in custom section so you can define /name you section properly in web.config. You could read the data as a hash table.&lt;br /&gt;
For example create section for the application .&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;Define a custom section &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; section name =&quot;MyApplicatinSection&quot;&lt;br /&gt;
type =&quot;System.Configuration.DictionarySectionHandler&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; MyApplicatinSection &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; SupportedExtensions &amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;Image&quot; value =&quot;.jpg,png&quot;/&amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;Video&quot; value =&quot;flv,wmv&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/ SupportedExtensions &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; SupportedServer &amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;AppServer&quot; value =&quot;server1,server2&quot;/&amp;gt;&lt;br /&gt;
&amp;lt; add key =&quot;ImageServer&quot; value =&quot;server4,server5&quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/ SupportedServer &amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;lt; MyApplicatinSection &amp;amp;gt&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Read the data from code&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;(System.Collections.Hashtable) System.Configuration.ConfigurationSettings.GetConfig(&quot;MyApplicatinSection&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Encrypting the web.config&lt;/b&gt; &lt;br /&gt;
Once we define the data in config we need to encrypt the data to keep the information secured. There are easy way to encrypt the sections.&lt;br /&gt;
1. Creat web.config entry&lt;br /&gt;
&amp;lt; section name =&quot;UserInfoSection&quot;&lt;br /&gt;
type =&quot;System.Configuration.SingleTagSectionHandler&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt; UserInfoSection username =&quot;value1&quot; password =&quot;value2&quot; domain =&quot;value3&quot;/&amp;gt;&lt;br /&gt;
2. Encrypt the section&lt;br /&gt;
Go to visual studio command prompt and run or go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727&lt;br /&gt;
aspnet_regiis –pef UserInfoSection &lt;br /&gt;
&lt;br /&gt;
3. Read the value from code&lt;br /&gt;
&lt;br /&gt;
MyUserData = (System.Collections.IDictionary)&lt;br /&gt;
System.Configuration.ConfigurationSettings.GetConfig(&quot; UserInfoSection &quot;);&lt;br /&gt;
Also read &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/zhhddkxy.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/5794835600355921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/creating-custom-sections-and-encrypting.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/5794835600355921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/5794835600355921'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/creating-custom-sections-and-encrypting.html' title='Creating Custom Sections and Encrypting the Section in web.config'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-4757024071512215018</id><published>2011-01-02T08:43:00.000-08:00</published><updated>2011-01-02T08:43:14.612-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Active Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><title type='text'>Active Directory (AD) - C# .NET</title><content type='html'>&lt;strong&gt;How to handle Active Directory in C#&lt;/strong&gt;&lt;br /&gt;
.Net Framework provides namespaces named &lt;strong&gt;System.DirectoryServices&lt;/strong&gt; and &lt;strong&gt;System.DirectoryServices.ActiveDirectory &lt;/strong&gt;to handle all the interaction with AD,&quot;Sounds exciting right!&quot;.This two namespces contains rich collection of classes , which provides n number of functionality to manage active directory.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Which classes allow us to perform basic functionality?&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;DirectoryEntry &lt;/strong&gt;: Represcent a node in Active Directory Domain Service Hierarchy.There is four overloads available for creating DirectoryEntry class&#39;s instance.&lt;br /&gt;
1. DirectoryEntry()&lt;br /&gt;
2. DirectoryEntry(string path) - Here parameter path means The path at which to&lt;br /&gt;
bind the System.DirectoryServices.DirectoryEntry. ex:- new DirectoryEntry&lt;br /&gt;
(&quot;LDAP://OU=PROJECTS,DC=MyDomain&quot;)&lt;br /&gt;
3. DirectoryEntry(string path, string username, string password) - here user&lt;br /&gt;
should be a AD user. Ex: new DirectoryEntry&lt;br /&gt;
(&quot;LDAP://OU=PROJECTS,DC=MyDomain&quot;,username,password)&lt;br /&gt;
4. DirectoryEntry(string path, string username, string password,&lt;br /&gt;
System.DirectoryServices.AuthenticationTypes authenticationType) - Here we have&lt;br /&gt;
to mention the authentication type .This overload is usefull when we are using&lt;br /&gt;
currently logged in /applcation identity as AD authentication user.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;DirectorySearcher&lt;/strong&gt; : This class is used to perform queries against Active Directory.This has 8 overloads for creating object here i am specifying only two.&lt;br /&gt;
1. DirectorySearcher() - simple creating instance.&lt;br /&gt;
2. System.DirectoryServices.DirectorySearcher.DirectorySearcher&lt;br /&gt;
(System.DirectoryServices.DirectoryEntry) - Passing Directory entry object, so&lt;br /&gt;
that will be the search root node for directory seracher.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;SearchResult&lt;/strong&gt; : Represcent a node in the active directory.This can be treated as directory entry object.&lt;br /&gt;
&lt;br /&gt;
How to Build LDAP Path ?&lt;br /&gt;
I saw many people are blindely get a copy from google and pasting it in their code without knowing about it.Have a look at the sample LDAP path&lt;br /&gt;
&lt;br /&gt;
&quot;LDAP://,ou=Marketing,dc=TestDomain&quot;&lt;br /&gt;
LDAP: provider (case sensitive)&lt;br /&gt;
ou - Organizational Unit&lt;br /&gt;
dc - Domain Component&lt;br /&gt;
cn - Common Name&lt;br /&gt;
&lt;strong&gt;Directory Service Providers&lt;/strong&gt;&lt;br /&gt;
Windows NT version 5.0, Windows 2000, or Windows XP - WinNT://path &lt;br /&gt;
Lightweight Directory Access Protocol (LDAP - LDAP://path &lt;br /&gt;
Novell NetWare Directory Service - NDS://path &lt;br /&gt;
Novell Netware 3.x - NWCOMPAT://path &lt;br /&gt;
Internet Information Services (IIS) - IIS:// &lt;br /&gt;
&lt;br /&gt;
So in a LDAP path you have to specify the Directory service provider,Specify the domain component and the organizational unit which you are looking for.Try to be more specific if you are not looking for all users in LDAP.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Following sample code reads all the user from Active Directory&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Add System.DirectoryServices reference&lt;/strong&gt;&lt;br /&gt;
using System.DirectoryServices;&lt;br /&gt;
&lt;br /&gt;
public void GetUsersList()&lt;br /&gt;
{&lt;br /&gt;
DirectoryEntry dntry = null;&lt;br /&gt;
DirectorySearcher dschr = null;&lt;br /&gt;
&lt;br /&gt;
//Creating Directory entry object with current application context user&lt;br /&gt;
dntry = new DirectoryEntry(&quot;Ldap path&quot;, null, null, AuthenticationTypes.Secure);&lt;br /&gt;
&lt;br /&gt;
// In the above line we are pasing user name and pasword as null so it will take &lt;br /&gt;
//current user credentials&lt;br /&gt;
//Create a searcher for this directory entry.&lt;br /&gt;
dschr = new DirectorySearcher(dntry);&lt;br /&gt;
&lt;br /&gt;
// Next i am going to specify the filter&lt;br /&gt;
dschr.Filter = &quot;(&amp;(objectCategory=person)(objectClass=user))&quot;;&lt;br /&gt;
&lt;br /&gt;
//Now i am going to specify which are the properties need to be loaded&lt;br /&gt;
//By specifying property we dont need to load unnecessary properties in AD.&lt;br /&gt;
dschr.PropertiesToLoad.Add(&quot;mail&quot;);&lt;br /&gt;
dschr.PropertiesToLoad.Add(&quot;name&quot;);&lt;br /&gt;
dschr.PropertiesToLoad.Add(&quot;userPrincipalName&quot;);&lt;br /&gt;
&lt;br /&gt;
//Loading result into search result collection&lt;br /&gt;
SearchResultCollection sResult = dschr.FindAll();&lt;br /&gt;
&lt;br /&gt;
//Loop through the collection&lt;br /&gt;
foreach (SearchResult sRlt in sResult)&lt;br /&gt;
{&lt;br /&gt;
//Get the property value&lt;br /&gt;
string sMailAddr = sRlt.Properties[&quot;mail&quot;][0].ToString();&lt;br /&gt;
}&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/4757024071512215018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/active-directory-ad-c-net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4757024071512215018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4757024071512215018'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/active-directory-ad-c-net.html' title='Active Directory (AD) - C# .NET'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-7121016070789102640</id><published>2011-01-02T08:13:00.001-08:00</published><updated>2011-01-02T08:13:54.880-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="control"/><category scheme="http://www.blogger.com/atom/ns#" term="file"/><category scheme="http://www.blogger.com/atom/ns#" term="upload"/><title type='text'>File Upload Ajax Control</title><content type='html'>It&#39;s quite common nowadays using ajax in asp.net development.In recent times many people came to me and complain that file upload is not working.&lt;br /&gt;
&lt;br /&gt;
For example you are using ajax tab control in asp.net page so the controls in your page will come inside the update panel.In that case there will be problem because we will normally set triggers for partial update,this will cause the file upload to fail.&lt;br /&gt;
&lt;br /&gt;
In a normal scenario people will set the ajax update panel like below.&lt;br /&gt;
&lt;br /&gt;
asp:updatepanel id=&quot;uppanel1&quot; updatemode=&quot;Conditional&quot; runat=&quot;server&quot;&lt;br /&gt;
//here the we will place the control need to be updated&lt;br /&gt;
triggers&lt;br /&gt;
asp:asyncpostbacktrigger eventname=&quot;SelectedIndexChanged&quot; controlid=&quot;ddlState&quot;&lt;br /&gt;
triggers&lt;br /&gt;
asp:updatepanel&lt;br /&gt;
asp:asyncpostbacktrigger&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Actually we can set two kind of triggers, one is AsyncPostBackTrigger and Postbacktrigger.One will cause partial update and other will raise normal full post back.&lt;br /&gt;
&lt;br /&gt;
here the trick on tab button click i will fire asynchronus postback trigger . in submit button click i will fire postback trigger.The reason i think already you know, File upload requires full post back if we are doing partial updates then it will not work. This issue will come only when we placed all the controls including submit button also within the update panel.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hope this will help people to stop cracking the heads&lt;br /&gt;
asp:asyncpostbacktrigger eventname=&quot;SelectedIndexChanged&quot; controlid=&quot;ddlState&quot;&lt;br /&gt;
asp:asyncpostbacktrigger eventname=&quot;Click&quot; controlid=&quot;btnData&quot;&lt;br /&gt;
asp:asyncpostbacktrigger eventname=&quot;Click&quot; controlid=&quot;btnHistory&quot;&lt;br /&gt;
asp:postbacktrigger controlid=&quot;btnSubmit&quot;&lt;br /&gt;
asp:postbacktrigger&lt;br /&gt;
asp:asyncpostbacktrigger&lt;br /&gt;
asp:asyncpostbacktrigger&lt;br /&gt;
asp:asyncpostbacktrigger&lt;br /&gt;
&lt;br /&gt;
asp:updatepanel id=&quot;uppanel1&quot; updatemode=&quot;Conditional&quot; runat=&quot;server&quot;&lt;br /&gt;
asp:updatepanel</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/7121016070789102640/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/file-upload-ajax-control.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/7121016070789102640'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/7121016070789102640'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2011/01/file-upload-ajax-control.html' title='File Upload Ajax Control'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-4095484935872424960</id><published>2010-11-03T16:23:00.000-07:00</published><updated>2010-11-03T16:23:47.591-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="current user"/><category scheme="http://www.blogger.com/atom/ns#" term="currentuser"/><category scheme="http://www.blogger.com/atom/ns#" term="sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="windows"/><title type='text'>How to Get Current User Name</title><content type='html'>All the developers might have coded atleast once for finding the current context User&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Windows Application&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
WindowsIdentity.GetCurrent().Name&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Environment.UserName&lt;br /&gt;
&lt;br /&gt;
System.Windows.Forms.SystemInformation.UserName&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Web Application&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
HttpContext.Current.User&lt;br /&gt;
WindowsIdentity.GetCurrent().Name&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;SharePoint&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
SPContext.Current.User</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/4095484935872424960/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/11/how-to-get-current-user-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4095484935872424960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4095484935872424960'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/11/how-to-get-current-user-name.html' title='How to Get Current User Name'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-8968147050549361517</id><published>2010-06-29T15:36:00.000-07:00</published><updated>2010-06-29T15:56:12.598-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="binary"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="conversion"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><title type='text'>Binary to String Conversion in C#</title><content type='html'>Converting binary to different format is quiet common scenario for developers.Its just two line of code that will do the magic , but when time matter love search in google so if this blog help someone really happy for that.&lt;br /&gt;&lt;strong&gt;Binary to String&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;&lt;strong&gt;&lt;/strong&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();&lt;br /&gt;string str = enc.GetString(MyByteArray); &lt;/span&gt;&lt;/blockquote&gt;if you want to make sure that there is no data loss then use Base64 Encoding&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Base64 Encoding&lt;/strong&gt; :- converts binary data to plain text using 64 case-sensitive, printable ASCII characters: A-Z, a-z, 0-9, plus sign (+) and forward slash (/), and may be terminated with 0-2 &quot;padding&quot; characters represented by the equal sign (=).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;Convert.ToBase64String(myByteArray);&lt;br /&gt;&lt;/span&gt;when you are working with picture it will be good to use Base64 conversion so you could make sure that there is no data lose</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/8968147050549361517/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/binary-to-string-conversion-in-c.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/8968147050549361517'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/8968147050549361517'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/binary-to-string-conversion-in-c.html' title='Binary to String Conversion in C#'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-5457303789632032590</id><published>2010-06-29T11:02:00.000-07:00</published><updated>2010-06-29T11:49:36.483-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="linq-to-xml"/><category scheme="http://www.blogger.com/atom/ns#" term="load"/><category scheme="http://www.blogger.com/atom/ns#" term="log4net"/><category scheme="http://www.blogger.com/atom/ns#" term="namespace"/><category scheme="http://www.blogger.com/atom/ns#" term="parse"/><category scheme="http://www.blogger.com/atom/ns#" term="Xdocumnet"/><category scheme="http://www.blogger.com/atom/ns#" term="xelement"/><category scheme="http://www.blogger.com/atom/ns#" term="xmlnamespace"/><title type='text'>XDocument or XElement with XmlNamespace</title><content type='html'>Loading or parsing xml with namspaces are common in development scenarios.When we work with Xdocument and XElement there is no direct way to pass the namespace. Let see how we can work with namspace.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Step1 Create a NameTable&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;NameTable nameTable = new NameTable();&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;strong&gt;Step2 Create Namespace Manager&lt;br /&gt;&lt;/strong&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XmlNamespaceManager nameSpaceManager = new XmlNamespaceManager(nameTable );&lt;/span&gt; &lt;/blockquote&gt;&lt;strong&gt;Step3 Add the Namespace or Ignore It&lt;br /&gt;&lt;/strong&gt;&lt;blockquote&gt;Adding&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;nameSpaceManager.AddNamespace(&quot;p&quot;, &quot;office.server.policy&quot;);&lt;/span&gt;&lt;br /&gt;Ignoring&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;nameSpaceManager.AddNamespace(&quot;log4net&quot;, &quot;urn:ignore&quot;);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;strong&gt;Step4 Create a ParserContext&lt;br /&gt;&lt;/strong&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XmlParserContext parserContext = new XmlParserContext(null, nameSpaceManager,&lt;br /&gt;null, XmlSpace.None);&lt;/span&gt; &lt;/blockquote&gt;&lt;strong&gt;Step5 Create a XmlTextReader&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XmlTextReader txtReader = new XmlTextReader(&quot;Strin XML&quot;, XmlNodeType.Element,&lt;br /&gt;parserContext);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;strong&gt;Step6 Load the XML&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XElement elem = XElement.Load(txtReader);&lt;/span&gt; &lt;/blockquote&gt;&lt;br /&gt;For Example we have a Log4net xml and we need to parse it&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color:#000066;&quot;&gt;&amp;lt;log4net:event logger=&quot;TestingTransmitter.Program&quot;&lt;br /&gt;timestamp=&quot;2009-08-02T17:50:18.928+01:00&quot;&lt;br /&gt;level=&quot;ERROR&quot;&lt;br /&gt;thread=&quot;9&quot;&lt;br /&gt;domain=&quot;TestingTransmitter.vshost.exe&quot;&lt;br /&gt;username=&quot;domain\user&quot;&amp;gt;&lt;br /&gt;&amp;lt;log4net:message&amp;gt;Log entry 103&amp;lt;/log4net:message&amp;gt;&lt;br /&gt;&amp;lt;log4net:properties&amp;gt;&lt;br /&gt;&amp;lt;log4net:data name=&quot;log4net:HostName&quot; value=&quot;machine&quot; /&amp;gt;&lt;br /&gt;&amp;lt;/log4net:properties&amp;gt;&lt;br /&gt;&amp;lt;/log4net:event&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Following code will load the xml without error like &quot;an undeclared namespace&quot;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;NameTable nameTable = new NameTable();&lt;br /&gt;XmlNamespaceManager nameSpaceManager&lt;br /&gt;= new XmlNamespaceManager(nameTable );&lt;br /&gt;nameSpaceManager.AddNamespace(&quot;log4net&quot;, &quot;urn:ignore&quot;);&lt;br /&gt;XmlParserContext&lt;br /&gt;parserContext = new XmlParserContext(null, nameSpaceManager,&lt;br /&gt;null,&lt;br /&gt;XmlSpace.None);&lt;br /&gt;XmlTextReader txtReader = new XmlTextReader(&quot;Strin XML&quot;,&lt;br /&gt;XmlNodeType.Element,&lt;br /&gt;parserContext );&lt;br /&gt;XElement elem =&lt;br /&gt;XElement.Load(txtReader); &lt;/span&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/5457303789632032590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/xdocument-or-xelement-with-xmlnamespace.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/5457303789632032590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/5457303789632032590'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/xdocument-or-xelement-with-xmlnamespace.html' title='XDocument or XElement with XmlNamespace'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-4260818234241842544</id><published>2010-06-24T10:17:00.000-07:00</published><updated>2010-06-24T10:35:49.596-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Error"/><category scheme="http://www.blogger.com/atom/ns#" term="Linq"/><category scheme="http://www.blogger.com/atom/ns#" term="MoveNext()"/><category scheme="http://www.blogger.com/atom/ns#" term="System.Linq.Enumerable.WhereListIterator"/><title type='text'>Object reference not set to an instance of an object at System.Linq.Enumerable.WhereListIterator`1.MoveNext()</title><content type='html'>Linq query are one of the favourite among the developers, sometimes people get following error in the Linq Query and became clueless.Error will look like following&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Object reference not set to an instance of an object at System.Linq.Enumerable.WhereListIterator`1.MoveNext()&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;For Example we have a query like following&lt;br /&gt;&lt;span style=&quot;color:#3333ff;&quot;&gt;cars = from car in Vehicle.Cars&lt;br /&gt;where car.Make.Contains(&quot;BMW&quot;)&lt;br /&gt;select car;&lt;br /&gt;we then enumerate through the cars like&lt;br /&gt;foreach (var myCar in cars)&lt;br /&gt;{&lt;br /&gt;//&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;the code starts blowing up in the enumeration with a error Object reference not set to an instance of an object at System.Linq.Enumerable.WhereListIterator`1.MoveNext()&lt;br /&gt;At first instance we may wonder why this is not working looks like the code has no issue. If we look at the query closely we can see the where condition &quot;&lt;strong&gt;&lt;span style=&quot;color:#ff0000;&quot;&gt;car.Make.Contains(&quot;BMW&quot;)&lt;/span&gt;&lt;/strong&gt; &quot; can blow up if the &lt;strong&gt;Make&lt;/strong&gt; is null. So we found the issue next we need to change the query like following&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;cars = from car in Vehicle.Cars&lt;br /&gt;where ((car.Make != null) &amp;amp;&amp;amp; (car.Make.Contains(&quot;BMW&quot;)))&lt;br /&gt;select car;&lt;/span&gt;&lt;br /&gt;Now we are good to go.Stop Googling !!!&lt;br /&gt;Cheers&lt;br /&gt;Shyju Mohan</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/4260818234241842544/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/object-reference-not-set-to-instance-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4260818234241842544'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/4260818234241842544'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/object-reference-not-set-to-instance-of.html' title='Object reference not set to an instance of an object at System.Linq.Enumerable.WhereListIterator`1.MoveNext()'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-1957770276313893488</id><published>2010-06-21T14:00:00.000-07:00</published><updated>2010-06-24T13:47:33.185-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="load"/><category scheme="http://www.blogger.com/atom/ns#" term="string"/><category scheme="http://www.blogger.com/atom/ns#" term="xdocument"/><category scheme="http://www.blogger.com/atom/ns#" term="xml"/><category scheme="http://www.blogger.com/atom/ns#" term="xmldocument"/><title type='text'>Loading xml from string</title><content type='html'>&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;strong&gt;XML Document Approach&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Let see how we can load xml from a string to a xmldocument&lt;br /&gt;object&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Step 1 Create XmlDocument Object&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:verdana;color:#3366ff;&quot;&gt;XmlDocument doc = new&lt;br /&gt;XmlDocument();&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Step 2&lt;br /&gt;Creat a StringReader Object&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:verdana;color:#3366ff;&quot;&gt;System.IO.StringReader sr = new&lt;br /&gt;System.IO.StringReader(&quot;XML&lt;br /&gt;Sring&quot;);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Step 3 Create&lt;br /&gt;XmlReader Object&lt;br /&gt;&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XmlReader xmlrd =&lt;br /&gt;XmlReader.Create(sr)&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Here we are calling XmlReader.Create method and passing a&lt;br /&gt;StringReader object&lt;br /&gt;&lt;strong&gt;Step 4 Load xml&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family:verdana;color:#3366ff;&quot;&gt;doc.Load(xmlrd);&lt;br /&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;span style=&quot;font-family:verdana;&quot;&gt;Uses Load method of&lt;br /&gt;XmlDocument object and pass XmlReader &lt;/span&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;&lt;span style=&quot;font-family:verdana;font-size:130%;&quot;&gt;XDocument Approach&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XDocument.Parse(&quot;StringXML&quot;, LoadOptions.PreserveWhitespace);&lt;/span&gt;&lt;br /&gt;In Xdocument you can directly pass the string and specify the load&lt;br /&gt;options.Even you can directly parse into a XElement&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XElement.Parse(&quot;StringXML&quot;)&lt;/span&gt;&lt;br /&gt;You could also specify the declaration for your xml when you are creating the XDocument.Look at the following line&lt;br /&gt;&lt;span style=&quot;color:#3366ff;&quot;&gt;XDocument xdoc = new XDocument(new XDeclaration(&quot;1.0&quot;, &quot;ISO-8859-1&quot;, &quot;YES&quot;), XElement.Parse(&quot;StringXML&quot;));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here XDeclaration you can specify version of xml,encoding you are using and standalone or not&lt;br /&gt;&lt;/blockquote&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/1957770276313893488/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/loading-xml-from-string.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/1957770276313893488'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/1957770276313893488'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/06/loading-xml-from-string.html' title='Loading xml from string'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8735280615943229552.post-8143053528692117121</id><published>2010-05-21T11:09:00.000-07:00</published><updated>2010-05-21T11:27:53.589-07:00</updated><title type='text'>Diagnostics and Logging In ASP.NET</title><content type='html'>I was playing diagnostic options in asp.net so thought of sharing the information with others.&lt;br /&gt;&lt;strong&gt;Scenario&lt;/strong&gt;&lt;br /&gt;* Log all warnings or above to the event log (So the people will notice it)&lt;br /&gt;* Log all information statements and warnings to text files in the application&#39;s&lt;br /&gt;directory.(It will help in detail to idenfy the issue)&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;lt;system.diagnostics&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;sources&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;source name=&quot;DefaultSource&quot; switchName=&quot;DefaultSwitch&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;listeners&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;add name=&quot;FileLog&quot;/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;add name=&quot;EventLog&quot;/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/listeners&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/source&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/sources&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;switches&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;add name=&quot;DefaultSwitch&quot; value=&quot;Information&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/switches&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;sharedListeners&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;add name=&quot;FileLog&quot;&lt;/p&gt;&lt;p&gt;type=&quot;Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL&quot; &lt;/p&gt;&lt;p&gt;initializeData=&quot;FileLogWriter&quot;/&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;add name=&quot;EventLog&quot; type=&quot;System.Diagnostics.EventLogTraceListener&quot; initializeData=&quot;Test Application&quot;&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;filter type=&quot;System.Diagnostics.EventTypeFilter&quot; &lt;/p&gt;&lt;p&gt;initializeData=&quot;Warning&quot; /&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/add&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/sharedListeners&amp;gt;&lt;/p&gt;&lt;p&gt;&amp;lt;/system.diagnostics&amp;gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://aspnetgotyou.blogspot.com/feeds/8143053528692117121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/05/diagnostics-and-logging-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/8143053528692117121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8735280615943229552/posts/default/8143053528692117121'/><link rel='alternate' type='text/html' href='http://aspnetgotyou.blogspot.com/2010/05/diagnostics-and-logging-in-aspnet.html' title='Diagnostics and Logging In ASP.NET'/><author><name>shyju mohan</name><uri>http://www.blogger.com/profile/11051605529571467169</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='28' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgT6sQuR9Mdy79E-Id5ADQv_C_PGu-hYArlw5ibD8sgmiqS8HZzA9eVWahPl3UQY3QcJk4s96RPo_bJC7TqwQf66wA17tRd36-mb2J7QcUqSiXZr2-thWj0MZLv6ClxOQ/s220/shyjupic.JPG'/></author><thr:total>0</thr:total></entry></feed>