<?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: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-4826856543136883832</id><updated>2011-10-13T22:23:13.772+06:00</updated><category term='Sharepoint Permission'/><category term='emailing'/><category term='Infragestics'/><category term='javascript'/><category term='PageRequestManger'/><category term='SQL server 2005'/><category term='AD Group'/><category term='UltraTree'/><category term='moss 2007'/><category term='compile error'/><category term='person or group field'/><category term='SQL query'/><category term='Page Validation.'/><category term='site restore'/><category term='server side scripting'/><category term='RegularExpressionValidator'/><category term='LinQ'/><category term='sharepoint'/><category term='SPRoleDefinition'/><category term='spfielduser'/><category term='node'/><category term='change status'/><category term='escape characters'/><category term='Event Handlers'/><category term='XmlTextWriter'/><category term='RequiredFieldValidator'/><category term='unicode'/><category term='Deligate'/><category term='client side scripting'/><category term='endedit'/><category term='SPRoleAssignment'/><category term='Attaching database'/><category term='Domain Login'/><category term='Asynchrous postback'/><category term='SPRoleAssignmentCollection'/><category term='SPGroup'/><category term='RunWithElevatedPrivileges'/><category term='web project'/><category term='checkbox'/><category term='site backup'/><category term='ASP .net'/><category term='visual studio 2008'/><category term='variable'/><category term='node unchecked'/><category term='transfer sharepoint feature'/><category term='Drag and Drop Framwork'/><category term='IEnumerable'/><category term='task list'/><category term='CustomValidator'/><category term='XML'/><category term='spfielduservalue'/><category term='postback'/><category term='SPUser'/><category term='Domain Group'/><category term='XmlAttribute'/><category term='drop down menu'/><category term='Filter'/><category term='UltraWebGrid'/><category term='feature'/><category term='UltraWebTree'/><category term='Active Directory'/><category term='unchecked'/><category term='Active Directory Users'/><category term='keydown'/><category term='wss 3.0'/><category term='editkeydown'/><category term='XmlNode'/><category term='activate feature'/><category term='keycode'/><title type='text'>Andalib's Technical Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>23</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-1785169499803306773</id><published>2010-07-15T15:43:00.003+06:00</published><updated>2010-07-15T15:51:28.047+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Filter'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraWebGrid'/><title type='text'>UltraWebGrid Get the current Filter Item from javascript</title><content type='html'>I had a problem where I needed to find which filter item I have chosen from the filter drop down. It's easy to get this from server side:&lt;br /&gt;&lt;br /&gt;((Infragistics.WebUI.UltraWebGrid.FilterCondition)(e.ActiveColumnFilter.FilterConditions.GetItem(0))).CompareValue&lt;br /&gt;&lt;br /&gt;But it seemed pretty difficult to find it from cilent side. In the end, I managed to find it. I used the "BeforeRowFilterApplied" client side event :&lt;br /&gt;&lt;br /&gt;function UltraWebGrid1_BeforeRowFilterApplied(gridName, oColumn)&lt;br /&gt;   {        $get("&amp;lt;%=tbFilterOperand.ClientID%&gt;").value=oColumn.Band.Grid._currentFilterDropped._evaluationValue;       &lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;It returned the filter item item (operand) that has been selected. I stored it inside the text field "tbFilterOperand" for later use.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-1785169499803306773?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/1785169499803306773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=1785169499803306773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/1785169499803306773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/1785169499803306773'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2010/07/ultrawebgrid-get-current-filter-item.html' title='UltraWebGrid Get the current Filter Item from javascript'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-3057976094312279350</id><published>2010-06-23T17:35:00.003+06:00</published><updated>2010-06-23T17:40:18.309+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RegularExpressionValidator'/><title type='text'>Validation expression to check Minimum length of 5 with trimming both ends</title><content type='html'>After spending some time I've been able to derive this expression:&lt;br /&gt;&lt;br /&gt;ValidationExpression="^[\s]*[\x21-\x7E][\x20-\x7E]{3,}[\x21-\x7E][\s]*$"&lt;br /&gt;&lt;br /&gt;It ignores if there is space/ tab at the beginning or at the end of the string. But it adds spaces in account if they come in between the beginning and ending charaters.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-3057976094312279350?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/3057976094312279350/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=3057976094312279350' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3057976094312279350'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3057976094312279350'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2010/06/validation-expression-to-check-minimum.html' title='Validation expression to check Minimum length of 5 with trimming both ends'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-1729131569283081415</id><published>2010-02-18T16:01:00.005+06:00</published><updated>2010-02-18T17:16:11.962+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='postback'/><title type='text'>Check Page.IsPostBack from Javascript</title><content type='html'>This cannot be done alone from Javascript. We need to use some help from the server file as well.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Add Postback check in the server file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the page_load of server file, Add this code:&lt;br /&gt;&lt;br /&gt;if (!Page.IsPostBack)&lt;br /&gt;      {&lt;br /&gt;          string Script = "var ranOnce = false;";         &lt;br /&gt;          this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "InitVariable", Script, true);&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;As we know !Page.IsPostBack check restricts execution to enter into the "if" block more than once after page has been loaded. We are declaring a javascript variable "ranOnce" from this block. RegisterClientScriptBlock adds the javascript code add the begining of page script, thats why we are using it because variables should be declared before the javascript function is declared.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Write the rest of the code in javascript:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;function Prepare() { &lt;br /&gt;      if(!ranOnce){&lt;br /&gt;          // your code here&lt;br /&gt;          ranOnce=true;&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;window.onload = Prepare;&lt;br /&gt;&lt;br /&gt;Because the function is attached to window.onload, it will run every time, but as we set "ranOnce" to false when the execution entered for the first time it will not execute again.&lt;br /&gt;&lt;br /&gt;Now, if  page refreshes (not postback), or user navigates back from other page, then from the server side, the "ranOnce" variable will be set to false again, and the function "Prepare" will execute once again.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-1729131569283081415?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/1729131569283081415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=1729131569283081415' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/1729131569283081415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/1729131569283081415'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2010/02/check-pageispostback-from-javascript.html' title='Check Page.IsPostBack from Javascript'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-534657826731126127</id><published>2010-01-21T10:55:00.012+06:00</published><updated>2010-01-21T12:04:58.545+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='XmlAttribute'/><category scheme='http://www.blogger.com/atom/ns#' term='XmlTextWriter'/><category scheme='http://www.blogger.com/atom/ns#' term='XML'/><category scheme='http://www.blogger.com/atom/ns#' term='XmlNode'/><title type='text'>Read and Write logs in XML file</title><content type='html'>If you dont want to use a DB, but still want to store, read data in a structured way, then xml is the best option. Its also used to send data over the internet.&lt;br /&gt;&lt;br /&gt;Lets take a look at how we can create, format, read, and write data into xml file. You need to add using System.xml class with your file&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Create an xml file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;XmlTextWriter xmltr = new XmlTextWriter(filePath, System.Text.Encoding.UTF8);&lt;br /&gt;        xmltr.Flush();&lt;br /&gt;        xmltr.Formatting = Formatting.Indented;&lt;br /&gt;        xmltr.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");&lt;br /&gt;        xmltr.WriteStartElement("ComponentLog");&lt;br /&gt;        xmltr.Close();&lt;br /&gt;&lt;br /&gt;We are using XmlTextWriter class to create the file. ComponentLog is the parent node in the xml file. An xml file can contain only 1 parent node.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Set format of the xml file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;XmlDocument doc = new XmlDocument();&lt;br /&gt;        doc.Load(filePath);&lt;br /&gt;        XmlNode node = doc.GetElementsByTagName("*")[0];&lt;br /&gt;&lt;br /&gt;        XmlAttribute xmlatr = doc.CreateAttribute("xmlns", "xsi", "http://www.w3.org/2000/xmlns/");&lt;br /&gt;        xmlatr.InnerText = "http://www.w3.org/2001/XMLSchema-instance";&lt;br /&gt;        XmlAttribute xmlatr2 = doc.CreateAttribute("xmlns", "xsd", "http://www.w3.org/2000/xmlns/");&lt;br /&gt;        xmlatr2.InnerText = "http://www.w3.org/2001/XMLSchema";&lt;br /&gt;&lt;br /&gt;        node.Attributes.Append(xmlatr);&lt;br /&gt;        node.Attributes.Append(xmlatr2);&lt;br /&gt;&lt;br /&gt;        XmlNode SQLnode = doc.CreateElement(ComponentType.SQLServer.ToString(), null);&lt;br /&gt;        XmlNode IndesignNode = doc.CreateElement(ComponentType.IndesignServer.ToString(), null);&lt;br /&gt;        XmlNode FSNode = doc.CreateElement(ComponentType.FS.ToString(), null);&lt;br /&gt;        node.AppendChild(SQLnode);&lt;br /&gt;        node.AppendChild(IndesignNode);&lt;br /&gt;        node.AppendChild(FSNode);&lt;br /&gt;        doc.AppendChild(node);&lt;br /&gt;        doc.Save(filePath);&lt;br /&gt;&lt;br /&gt;filepath is a string contains the full path of the xml file including filename and extension. We use XmlDocument to read the file first, then format it. It would obviously get only 1 node which we created earlier named "ComponentLog". Then we have added 2 attributes with this parent node. Next with this parent ode "ComponentLog" we have added 3 child nodes. We are storing 3 types of log information in the xml file. They are: SQL, Indesign, and FileSystem. That completed our formatting with the xml file.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Write log data into xml file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public static void WriteXmlLog(ComponentType CType, int CStatus, string userId, string userName, string email, DateTime lastMailSent,string culturecode)&lt;br /&gt;{&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        if (!File.Exists(filePath))&lt;br /&gt;        {&lt;br /&gt;            CreateXmlFile();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        XmlDocument doc = new XmlDocument();&lt;br /&gt;&lt;br /&gt;        doc.Load(filePath);&lt;br /&gt;        XmlNodeList baseNodes = doc.GetElementsByTagName(CType.ToString());&lt;br /&gt;&lt;br /&gt;        XmlNode node = doc.CreateNode(XmlNodeType.Element, CType.ToString() + "Log", null);&lt;br /&gt;&lt;br /&gt;        XmlNode UserId = doc.CreateElement("UserId");&lt;br /&gt;        UserId.InnerText = userId;&lt;br /&gt;&lt;br /&gt;        XmlNode UserName = doc.CreateElement("UserName");&lt;br /&gt;        UserName.InnerText = userName;&lt;br /&gt;&lt;br /&gt;        XmlNode Email = doc.CreateElement("Email");&lt;br /&gt;        Email.InnerText = email;&lt;br /&gt;&lt;br /&gt;        XmlNode LastMailSent = doc.CreateElement("LastMailSent");&lt;br /&gt;        LastMailSent.InnerText = lastMailSent.ToString();&lt;br /&gt;&lt;br /&gt;        XmlNode ComponentStatus = doc.CreateElement("ComponentStatus");&lt;br /&gt;        ComponentStatus.InnerText = CStatus.ToString();&lt;br /&gt;&lt;br /&gt;        XmlNode Culturecode = doc.CreateElement("culturecode");&lt;br /&gt;        Culturecode.InnerText = culturecode;&lt;br /&gt;&lt;br /&gt;        // add children to father&lt;br /&gt;        node.AppendChild(UserId);&lt;br /&gt;        node.AppendChild(UserName);&lt;br /&gt;        node.AppendChild(Email);&lt;br /&gt;        node.AppendChild(LastMailSent);&lt;br /&gt;        node.AppendChild(ComponentStatus);&lt;br /&gt;        node.AppendChild(Culturecode);&lt;br /&gt;&lt;br /&gt;        // append the new node&lt;br /&gt;        baseNodes[0].AppendChild(node);&lt;br /&gt;&lt;br /&gt;        // save the file&lt;br /&gt;        doc.Save(filePath);&lt;br /&gt;    }&lt;br /&gt;    catch (Exception ex)&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;First, we check whether a file already exists in that path or not. If not, then we create a new one. Then, we get the node that defines type of our log. CType is the enum that defines the type of log data we will write (FS, Indesign, or SQL).&lt;br /&gt;XmlNodeList baseNodes = doc.GetElementsByTagName(CType.ToString()); returns nodes that have same tagname. baseNodes[0] (Lets call this as the "typeRoot" node) will return the topmost node of that type, which is added with the parent node "ComponentLog". with the typeRoot node, we want to add log data. So basically, we have created a node named "node", created respective nodes to store info such as userId, userName, email, lastMailSent,  culturecode. Then we have added this info nodes under the newly created node "node", then added "node" under the "typeRoot" node. Under the 'typeRoot" node there will be multiple entries of "node". Their tag name is same to their "typeRoot" node, just the extra "log" string is added to the end of their name. Then we save (overwrite) the existing doc file. The xml file looks like this (using IE):&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_quJAko6OL8I/S1ftfbcTy9I/AAAAAAAAAJk/6pL6yaCFIX0/s1600-h/blog3.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 453px; height: 549px;" src="http://2.bp.blogspot.com/_quJAko6OL8I/S1ftfbcTy9I/AAAAAAAAAJk/6pL6yaCFIX0/s400/blog3.jpg" alt="" id="BLOGGER_PHOTO_ID_5429069000016645074" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Read from xml file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;public static DataTable ReadXML(ComponentType ctype)&lt;br /&gt;{&lt;br /&gt;    DataSet ds = new DataSet();&lt;br /&gt;    DataTable dt = new DataTable();&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;        ds.ReadXml(filePath);&lt;br /&gt;        if (ds != null)&lt;br /&gt;        {&lt;br /&gt;            if (ctype.ToString() == ComponentType.SQLServer.ToString())&lt;br /&gt;            {&lt;br /&gt;                dt = ds.Tables[ComponentType.SQLServer.ToString() + "Log"];&lt;br /&gt;            }&lt;br /&gt;            else if (ctype.ToString() == ComponentType.IndesignServer.ToString())&lt;br /&gt;            {&lt;br /&gt;                dt = ds.Tables[ComponentType.IndesignServer.ToString() + "Log"];&lt;br /&gt;            }&lt;br /&gt;            else if (ctype.ToString() == ComponentType.FS.ToString())&lt;br /&gt;            {&lt;br /&gt;                dt = ds.Tables[ComponentType.FS.ToString() + "Log"];&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    catch&lt;br /&gt;    {&lt;br /&gt;        dt = null;&lt;br /&gt;    }&lt;br /&gt;    return dt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;DataSet.ReadXml("FilePath") directly reads the whole xml file in form of a dataset. Then, from the dataset we get our desired type of node collection if form of table. All the info node automatically created a column and their values created rows of the table. Thats how we read info from xml file.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-534657826731126127?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/534657826731126127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=534657826731126127' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/534657826731126127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/534657826731126127'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2010/01/read-and-write-logs-in-xml-file.html' title='Read and Write logs in XML file'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_quJAko6OL8I/S1ftfbcTy9I/AAAAAAAAAJk/6pL6yaCFIX0/s72-c/blog3.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-7184649225368106373</id><published>2009-11-26T09:52:00.008+07:00</published><updated>2009-11-26T10:56:23.414+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='Page Validation.'/><category scheme='http://www.blogger.com/atom/ns#' term='CustomValidator'/><title type='text'>Read Page.IsValid from javascript (alternate way)</title><content type='html'>This was my scenario:&lt;br /&gt;In a form there are few fields and 2 buttons :"Save" and "Cancel"&lt;br /&gt;If user presses save button, and if the form validation is true, then immediately disable the "Cancel" button, so that the user cannot press the "Cancel" button. Here is the form:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_quJAko6OL8I/Sw32A84yyxI/AAAAAAAAAJA/LQDL7ygMVTg/s1600/departmentChanged.JPG"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 320px; height: 253px;" src="http://1.bp.blogspot.com/_quJAko6OL8I/Sw32A84yyxI/AAAAAAAAAJA/LQDL7ygMVTg/s320/departmentChanged.JPG" alt="" id="BLOGGER_PHOTO_ID_5408249223746603794" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"Name" field is a required field. So there is a "RequiredFieldValidator" attached with it. I have to disable the cancel button from javascript if:&lt;br /&gt;1. User presses "Save" button.&lt;br /&gt;2. Name field has some value (page validation passed).&lt;br /&gt;&lt;br /&gt;To do this, I had to add a customvalidator with the name field, and do the javascript coding inside its client side function. Here is the code for the field and the validators:&lt;br /&gt;&lt;br /&gt;&amp;lt;td&gt;&lt;br /&gt;&amp;lt;asp:TextBox ID="uxName" runat="server" MaxLength="50" width="180px"&gt;&amp;lt;/asp:TextBox&gt;&lt;br /&gt;                 &lt;br /&gt;&amp;lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="uxName" SetFocusOnError="true"&lt;br /&gt;                         ErrorMessage="Department name cannot be empty" ValidationGroup="DepartmentEditValidation"&gt;*&amp;lt;/asp:RequiredFieldValidator&gt;&lt;br /&gt;             &lt;br /&gt;&amp;lt;asp:CustomValidator runat="server" ID="uxCustomValidator" ClientValidationFunction="checkNames" ControlToValidate="uxName" ValidationGroup="DepartmentEditValidation" ErrorMessage="" SetFocusOnError="True" Display="Dynamic"&gt;&lt;br /&gt;&amp;lt;/asp:CustomValidator&gt;&lt;br /&gt;                 &lt;br /&gt;&amp;lt;/td&gt;&lt;br /&gt;&lt;br /&gt;Here is the code for Save, and Cancel button. Validation Group has to be same for the Save button.&lt;br /&gt;&lt;br /&gt;&amp;lt;div class="editPanelButton"&gt;&lt;br /&gt;          &amp;lt;asp:Button ID="uxSave" runat="server" Text="&amp;lt;%$Resources:Texts,Save %&gt;" ValidationGroup="DepartmentEditValidation"&lt;br /&gt;              OnClick="uxSave_Click" /&gt;&lt;br /&gt;          &amp;lt;asp:Button ID="uxCancel" runat="server" Text="&amp;lt;%$Resources:Texts,Cancel %&gt;" OnClick="uxCancel_Click" /&gt;&lt;br /&gt;      &lt;&amp;lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Now we need to do the javascript checking inside the clientside function of the customfield validator. We declared: ClientValidationFunction="checkNames", so here is the function:&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript" &gt;&lt;br /&gt;function checkNames(source, args){&lt;br /&gt;&lt;br /&gt;   if(args.IsValid){&lt;br /&gt;     &lt;br /&gt;       if(event.srcElement.id==uxSaveButtonClientId){&lt;br /&gt;           document.getElementById(uxCancelButtonClientId).disabled=true;&lt;br /&gt;       }&lt;br /&gt;       args.isValid=true;&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt; &lt;br /&gt;&amp;lt;/script&gt;&lt;br /&gt;&lt;br /&gt;args.IsValid is the alternate way of checking whether the page validation is true or not. Then I checked the validation was fired by pressing the "save" button. validation also fires when focus goes out from the "uxname" text field. So, I needed to be specific. If the conditions pass the I disabled the cancel button. This solved my problem.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-7184649225368106373?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/7184649225368106373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=7184649225368106373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/7184649225368106373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/7184649225368106373'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/11/read-pageisvalid-from-javascript.html' title='Read Page.IsValid from javascript (alternate way)'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_quJAko6OL8I/Sw32A84yyxI/AAAAAAAAAJA/LQDL7ygMVTg/s72-c/departmentChanged.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-3112678693030722477</id><published>2009-08-25T13:13:00.005+07:00</published><updated>2009-08-25T15:50:06.602+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PageRequestManger'/><category scheme='http://www.blogger.com/atom/ns#' term='Asynchrous postback'/><title type='text'>Disable asynchronous postbacks while one asynchronous postback is active.</title><content type='html'>A&lt;span&gt;synchronous postbacks are partial postbacks occured by Ajax (or any other 3rd party) update panels. Ajax has 5 stages to handle the life cycle of an &lt;/span&gt;&lt;span&gt;asynchronous postback. They are:&lt;br /&gt;&lt;br /&gt;1. initializeRequest&lt;br /&gt;2. beginRequest&lt;br /&gt;3. pageLoading&lt;br /&gt;4. pageLoaded&lt;br /&gt;5. endRequest&lt;br /&gt;&lt;br /&gt;For our work, we need to handle the initializeRequest only. First make sure that your page contains ScriptManager, UpdatePanel, and UpdateProgress controls.&lt;br /&gt;&lt;br /&gt;Now, if you want to keep the existing async postback alive, and kill all new async postbacks that are occuring, then add this script:&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&gt;              &lt;br /&gt;               var prm = Sys.WebForms.PageRequestManager.getInstance();                          &lt;br /&gt;prm.add_initializeRequest(InitializeRequest);&lt;br /&gt;               &lt;/span&gt;&lt;span&gt;&lt;span id="ctl00_MTContentSelector1_mainContentContainer_ctl112_ctl00_ctl29"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;br /&gt;               function &lt;/span&gt;&lt;span&gt;InitializeRequest&lt;/span&gt;&lt;span&gt;(sender, args) {&lt;br /&gt;                   if (prm.get_isInAsyncPostBack()) {                      &lt;br /&gt;                       args.set_cancel(true);&lt;br /&gt;                   }&lt;br /&gt;               }&lt;br /&gt;&amp;lt;/script&gt;&lt;br /&gt;&lt;br /&gt;if you want to kill the existing async postback and start the new one, then replace the above function with this one:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span&gt; function &lt;/span&gt;&lt;span&gt;InitializeRequest&lt;/span&gt;&lt;span&gt;(sender, args) {&lt;/span&gt;&lt;br /&gt;&lt;span&gt;if(prm.get_isInAsyncPostBack(){&lt;br /&gt;prm.abortPostBack();&lt;br /&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-3112678693030722477?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/3112678693030722477/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=3112678693030722477' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3112678693030722477'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3112678693030722477'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/08/disable-asynchronous-postbacks-while.html' title='Disable asynchronous postbacks while one asynchronous postback is active.'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-8801126344483169483</id><published>2009-07-27T11:59:00.012+07:00</published><updated>2009-08-25T13:44:26.777+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='RequiredFieldValidator'/><category scheme='http://www.blogger.com/atom/ns#' term='CustomValidator'/><title type='text'>Read from DB while clientside validation using asp:CustomValidator (Bypass)</title><content type='html'>Ok, by saying bypass, I mean I didnt read data from SQL server table while the client side validation. I read it earlier, stored data in a hidden listbox, and used customvalidator to perform the client side validation . Here's how:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Declare a hidden list box that can be readable by javascript:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:ListBox ID="uxHiddenListBoxForPermissionName" runat="server" Style="display:none"&gt;&lt;br /&gt;&amp;lt;/asp:ListBox&gt;&lt;br /&gt;&lt;br /&gt;Style="display:none" keeps the item hidden as well as readable by javascript. For my work I needed to add another hidden item, just to make sure that it is an update or add operation:&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:TextBox ID="uxTextBoxLog" runat="server" Style="display:none"&gt;&lt;br /&gt;&amp;lt;/asp:TextBox&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2. Populate data into the listbox from the code behind file:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Put this method in the code behind file (.cs):&lt;br /&gt;private void GenerateHiddenListBox()&lt;br /&gt;{&lt;br /&gt;uxHiddenListBoxForPermissionName.Items.Clear();&lt;br /&gt;ListItem item;&lt;br /&gt;DataRowCollection rowCollection = Manager.GetManager().RoleManager.GetPermissions().Rows;&lt;br /&gt;foreach (DataRow row in rowCollection)&lt;br /&gt;{&lt;br /&gt;   item = new ListItem();&lt;br /&gt;   item.Value = row["Id"].ToString();&lt;br /&gt;   item.Text = row["Name"].ToString();&lt;br /&gt;   uxHiddenListBoxForPermissionName.Items.Add(item);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Manager.GetManager().RoleManager.GetPermissions() is the method that is used to read the table from DB. Replace it with yours. You should run this method each time there has been any change in the table (ex: new row added/ existing row modified/ deleted)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;3. Add the customValidator to the field that you want to validate, along with other validators (if any):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;tr valign="top"&gt;&lt;br /&gt;   &amp;lt;td style="width: 20%"&gt;&lt;br /&gt;       &amp;lt;asp:Label ID="Label7" runat="server" Text="&amp;lt;%$Resources:Texts,Name %&gt;"&gt;&amp;lt;/asp:Label&gt;&lt;br /&gt;   &amp;lt;/td&gt;&lt;br /&gt;   &amp;lt;td style="width: 40%"&gt;&lt;br /&gt;       &amp;lt;asp:TextBox ID="uxName" runat="server" MaxLength="50" Width="97%"&gt;&amp;lt;/asp:TextBox&gt;&lt;br /&gt;   &amp;lt;/td&gt;&lt;br /&gt;   &amp;lt;td style="width: 40%"&gt; &lt;br /&gt;&lt;br /&gt;       &amp;lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"&lt;br /&gt;           ValidationGroup="PermissionValidation" ControlToValidate="uxName" SetFocusOnError="true" Display="Dynamic"&gt;&amp;lt;/asp:RequiredFieldValidator&gt;&lt;br /&gt;&lt;br /&gt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;&lt;br /&gt;    &amp;lt;asp:CustomValidator runat="server" ID="uxCustomValidator" ClientValidationFunction="checkNames"&lt;br /&gt;      ControlToValidate="uxName" ValidationGroup="PermissionValidation" ErrorMessage="&lt;/asp:customvalidator&gt;&amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;%$Resources:Texts,PermissionNameAlreadyExists %&gt;" SetFocusOnError="True" Display="Dynamic"&gt;&lt;br /&gt;      &lt;/asp:customvalidator&gt;&amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;/asp:CustomValidator&gt;&lt;br /&gt;&lt;br /&gt;&lt;/asp:customvalidator&gt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;&lt;/asp:customvalidator&gt;             &amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;/td&gt;&lt;br /&gt;&lt;/asp:customvalidator&gt;             &amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;/tr&gt;&lt;br /&gt;&lt;br /&gt;here I am validaing the uxName field. I'm using the asp:RequiredFieldValidator to check the field is nonempty, and using the asp:CustomValidator to check whether the entry already exists or not.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;4. Write the client side function to perform the validation (this function is referred from asp:customvalidator):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript" &gt;&lt;br /&gt;&lt;br /&gt;function checkNames(source, args){&lt;br /&gt;var permissionNameList= document.getElementById(uxPermissionListClientId);&lt;br /&gt;var nameField= document.getElementById(uxNameClientId);&lt;br /&gt;//alert(permissionNameList.length);&lt;br /&gt;//        alert(nameField.value);&lt;br /&gt;var logText= document.getElementById(uxTextBoxLogClientId).value;&lt;br /&gt;//alert(logText);&lt;br /&gt;if(logText=='New'){ //I've set the value of textbox to 'New' while performing add operation&lt;br /&gt;    for(var i=0;i&lt;/asp:customvalidator&gt;             &amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;permissionNameList.length;i++){&lt;br /&gt;        //alert(permissionNameList.options[i].text);&lt;br /&gt;&lt;br /&gt;        if(permissionNameList.options[i].text==nameField.value){&lt;br /&gt;//                alert('validation is false, brother');&lt;br /&gt;            args.IsValid=false;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;else{ //else I've set the value of the hidden text field to the current item to exclude it from comparing.&lt;br /&gt;    for(var i=0;i&lt;/asp:customvalidator&gt;             &amp;lt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;permissionNameList.length;i++){&lt;br /&gt;        //alert(permissionNameList.options[i].text);&lt;br /&gt;&lt;br /&gt;        if(permissionNameList.options[i].text==nameField.value&amp;amp;&amp;amp;nameField.value!=logText){&lt;br /&gt;//                alert('validation is false, brother');&lt;br /&gt;            args.IsValid=false;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&gt;&lt;br /&gt;&lt;br /&gt;&lt;permissionnamelist.length;i++){ else="" set="" the="" value="" to="" current="" becuase="" that="" item="" should="" be="" excluded="" from="" checking="" var="" i="" text="=nameField.value){" validation="" is="" brother="" isvalid="false;" script=""&gt;uxPermissionListClientId is the client id for list box where data is stored reading from table, uxNameClientId is the client id of the textbox for which the validation is being performed, and uxTextBoxLogClientId is the client id of uxTextBoxLog, the hidden text box where I keep track whether an adding or updating event is going on. setting args.IsValid=false means there is an error, validation will not pass, and postback will not occure.&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;&lt;permissionnamelist.length;i++){ else="" set="" the="" value="" to="" current="" becuase="" that="" item="" should="" be="" excluded="" from="" checking="" var="" i="" text="=nameField.value){" validation="" is="" brother="" isvalid="false;" script=""&gt;&lt;asp:customvalidator runat="server" id="uxCustomValidator" clientvalidationfunction="checkNames" controltovalidate="uxName" validationgroup="PermissionValidation" errormessage=""&gt;&lt;permissionnamelist.length;i++){ else="" set="" the="" value="" to="" current="" becuase="" that="" item="" should="" be="" excluded="" from="" checking="" var="" i="" text="=nameField.value){" validation="" is="" brother="" isvalid="false;" script=""&gt;&lt;/permissionnamelist.length;i++){&gt;&lt;/asp:customvalidator&gt;&lt;/permissionnamelist.length;i++){&gt;&lt;/asp:customvalidator&gt;&lt;/permissionnamelist.length;i++){&gt;&lt;/asp:customvalidator&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-8801126344483169483?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/8801126344483169483/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=8801126344483169483' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/8801126344483169483'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/8801126344483169483'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/07/read-from-db-while-clientside.html' title='Read from DB while clientside validation using asp:CustomValidator (Bypass)'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-9221884271677226940</id><published>2009-06-30T10:37:00.005+07:00</published><updated>2009-06-30T11:20:26.778+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Drag and Drop Framwork'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraWebTree'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraTree'/><category scheme='http://www.blogger.com/atom/ns#' term='node'/><category scheme='http://www.blogger.com/atom/ns#' term='Infragestics'/><title type='text'>Drag and Drop UltraWebTree nodes in Mozilla Firefox using Infragistics Drag and Drop Framework</title><content type='html'>Infragistics dont support drag and drop tree nodes for UltraWebTree in Firefox. To go around this, you need to use Infragistics drag and drop Framework.&lt;br /&gt;&lt;br /&gt;First, in your project/ website, add this reference: "Infragistics2.Web.v9.1" if Infra CLR 2.0 is installed. For CLR 3.5, you should add: "Infragistics35.Web.v9.1". Its a bit tricky to add it in websites. For websites, you may need to copy the dll into the deploy folder first. Then add the reference in the website.&lt;br /&gt;&lt;br /&gt;Then,  in your usercontrol, or page, or in master page (whichever applicable) add these assembly:&lt;br /&gt;&lt;br /&gt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;&amp;lt;asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"&lt;br /&gt;  AsyncPostBackTimeout="9600"&gt;&lt;br /&gt;  &amp;lt;Scripts&gt;&lt;br /&gt;  &lt;/asp:scriptmanager&gt;&amp;lt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;asp:ScriptReference Assembly="Infragistics2.Web.v9.1, Version=9.1.20091.2040, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Name="Infragistics.Web.UI.SharedScripts.igDragDrop.js" /&gt;&lt;br /&gt;  &lt;/asp:scriptmanager&gt;&amp;lt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;asp:ScriptReference Assembly="Infragistics2.Web.v9.1, Version=9.1.20091.2040, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Name="Infragistics.Web.UI.Scripts.5_igObjects.js" /&gt;&lt;br /&gt;&lt;/asp:scriptmanager&gt;&amp;lt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;/Scripts&gt;&lt;br /&gt;&lt;/asp:scriptmanager&gt;&amp;lt;&lt;asp:scriptmanager id="ScriptManager1" runat="server"&gt;/asp:ScriptManager&gt;&lt;scripts&gt;&lt;asp:scriptreference assembly="Infragistics2.Web.v9.1, Version=9.1.20091.2040, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" name="Infragistics.Web.UI.SharedScripts.igDragDrop.js"&gt;&lt;asp:scriptreference assembly="Infragistics2.Web.v9.1, Version=9.1.20091.2040, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" name="Infragistics.Web.UI.Scripts.5_igObjects.js"&gt;&lt;/asp:scriptreference&gt;&lt;/asp:scriptreference&gt;&lt;br /&gt;&lt;br /&gt;You need to be careful about the CLR and version of the infragistics. Here, the version is 2040. But you can check it from your web.config, which version of infragistics is installed in your PC. Use your own version in the string.&lt;br /&gt;&lt;br /&gt;In the page/ usercontrol, add this script:&lt;br /&gt;&lt;br /&gt;&amp;lt;script type="text/javascript"&gt;&lt;br /&gt;Sys.Application.add_load(app_loaded);&lt;br /&gt;&lt;br /&gt;function app_loaded()&lt;br /&gt;{&lt;br /&gt;InitiateDragDropFrameWorkToNodes();&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&gt;&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;    Sys.Application.add_load(app_loaded);&lt;br /&gt;&lt;br /&gt;    function app_loaded()&lt;br /&gt;    {&lt;br /&gt;     InitiateDragDropFrameWorkToNodes();  &lt;br /&gt;    }&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;This must follow the script manager.&lt;br /&gt;&lt;br /&gt;now add scripts in a separate javascript file, and reference it in the page/ usercontrol. I always prefer to use a separate javascript file, because it allows you to debug the script. Add this in the .js file:&lt;br /&gt;&lt;br /&gt;var ddR = new $IG.DragDropBehavior();&lt;br /&gt;var dropLoop=true;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function InitiateDragDropFrameWorkToNodes()&lt;br /&gt;{&lt;br /&gt; var treeInstance = igtree_getTreeById(UltraWebTreeClientID); //tree client id passed from pageload.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; var firstlevel=treeInstance.getNodes();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; //loops through all the first level nodes, usually there wont be more than 1 in our project&lt;br /&gt;&lt;br /&gt; for(var i=0;i&amp;lt;firstlevel.length;i++)&lt;br /&gt; {&lt;br /&gt;     var treeNode= firstlevel[i];&lt;br /&gt;     ddR.addSourceElement(treeNode.getElement());//this line was not needed, but if the root node is not included, then infra's built in drag drop starts, and gives different look.&lt;br /&gt;     ddR.addTargetElement(treeNode.getElement());&lt;br /&gt;     if(treeNode.hasChildren())&lt;br /&gt;     {&lt;br /&gt;         AssaignDragSource(treeNode);&lt;br /&gt;     }  &lt;br /&gt;&lt;br /&gt; }&lt;br /&gt; if(ddR._events._handlers.Drop==null||ddR._events._handlers.Drop.length&amp;lt;1){ //this is the most important line, handler should be added only once and not again.&lt;br /&gt;     ddR.get_events().addDropHandler(drop);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function AssaignDragSource( treeNode)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt; var children=treeNode.getChildNodes();  &lt;br /&gt;&lt;br /&gt; for(var j=0;j&amp;lt;children.length;j++)&lt;br /&gt; {   &lt;br /&gt; &lt;br /&gt;     var element=children[j].getElement();    &lt;br /&gt;     ddR.addSourceElement(element);&lt;br /&gt;     ddR.addTargetElement(element, true);&lt;br /&gt;&lt;br /&gt;     if(children[j].hasChildren())&lt;br /&gt;     {&lt;br /&gt;         AssaignDragSource(children[j]); //recursively call all children to add dragdropbehavior&lt;br /&gt;     &lt;br /&gt;     &lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function drop(sender, eventArgs) {&lt;br /&gt; if ( dropLoop==true){&lt;br /&gt;&lt;br /&gt;     var treeInstance = igtree_getTreeById(UltraWebTreeClientID);&lt;br /&gt;     var source = eventArgs.get_manager().get_source().element;&lt;br /&gt;     var startNode=treeInstance.getNodeById(source.id);&lt;br /&gt;     var startNodes = startNode.getChildNodes();&lt;br /&gt;     var target= eventArgs.get_manager().get_target().element;&lt;br /&gt;     var endNode=treeInstance.getNodeById(target.id);&lt;br /&gt;     if(startNode==endNode){&lt;br /&gt;     &lt;br /&gt;         return;&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;    // alert('I am here');&lt;br /&gt;&lt;br /&gt;    var parentNode = endNode.getParent();&lt;br /&gt;     while (parentNode != null) {&lt;br /&gt;         if (parentNode == startNode) {&lt;br /&gt;             dropLoop=false;//whenever an alert is shown, it reenters the drop event even return is called, its fixed here&lt;br /&gt;             alert(msgCannotMoveParentUnderChild);            &lt;br /&gt;             return;&lt;br /&gt;         }&lt;br /&gt;         parentNode = parentNode.getParent();&lt;br /&gt;     }&lt;br /&gt; &lt;br /&gt;     CopyNode(endNode, startNode);&lt;br /&gt;     //endNode.addChild(startNode.getText());&lt;br /&gt;     if (startNode.hasChildren()) {&lt;br /&gt;         addDroppedChildren(endNode.getChildNodes()[endNode.getChildNodes().length - 1], startNodes);&lt;br /&gt;     }&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;     startNode.remove();&lt;br /&gt; &lt;br /&gt; &lt;br /&gt;     igtree_needPostBack(UltraWebTreeClientID);&lt;br /&gt;     var ts = igtree_treeState[UltraWebTreeClientID];&lt;br /&gt;     __doPostBack(ts.UniqueId,  endNode.element.id + ":Update");&lt;br /&gt; }&lt;br /&gt; dropLoop=true; //allow to enter drop function after the alert message hastle is over.&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function CopyNode(toNode, fromNode) {&lt;br /&gt;&lt;br /&gt; newNode = toNode.addChild(fromNode.getText());&lt;br /&gt; newNode.setTag(fromNode.getTag());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function addDroppedChildren(endNode, startNodes) {&lt;br /&gt;&lt;br /&gt; for (var i = 0; i &amp;lt; startNodes.length; i++) {&lt;br /&gt;     CopyNode(endNode, startNodes[i]);&lt;br /&gt;     //endNode.addChild(startNodes[i].getText());&lt;br /&gt;     if (startNodes[i].hasChildren()) {&lt;br /&gt;         addDroppedChildren(endNode.getChildNodes()[endNode.getChildNodes().length - 1], startNodes[i].getChildNodes());&lt;br /&gt;     }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;}&lt;firstlevel.length;i++)&gt;&lt;children.length;j++)"&gt;&lt;br /&gt;&lt;br /&gt;This will allow you to drag and drop tree nodes (including children nodes) in firefox. These two posts was really helpful with drag and drop framework:&lt;br /&gt;&lt;a href="http://community.infragistics.com/blogs/sung_kim/archive/2008/08/08/drop-it-like-its-windows-drag-and-drop-on-the-web.aspx"&gt;Drop it Like its Windows&lt;/a&gt;&lt;br /&gt;&lt;/children.length;j++)"&gt;&lt;/firstlevel.length;i++)&gt;&lt;/scripts&gt;&lt;/asp:scriptmanager&gt;&lt;a href="http://blogs.infragistics.com/aspnet/articles/introduction-to-the-infragistics-web-drag-and-drop-framework.aspx"&gt;Introduction to the Infragistics Web Drag and Drop Framework&lt;/a&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-9221884271677226940?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/9221884271677226940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=9221884271677226940' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9221884271677226940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9221884271677226940'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/06/drag-and-drop-ultrawebtree-nodes-in.html' title='Drag and Drop UltraWebTree nodes in Mozilla Firefox using Infragistics Drag and Drop Framework'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-4954000296036657112</id><published>2009-06-10T16:33:00.004+06:00</published><updated>2009-06-10T16:55:13.593+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='RegularExpressionValidator'/><title type='text'>Use RegularExpressionValidator to validate a URL / web address</title><content type='html'>This is a nice RegularExpressionValidator to validate URLs:&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"&lt;br /&gt;                  ControlToValidate="uxRssUrl" ErrorMessage="&amp;lt;%$ Resources:Texts, InvalidUrl %&gt;"&lt;br /&gt;                  &lt;span style="color: rgb(102, 51, 255);"&gt;ValidationExpression="^(ht|f)tp(s?)\:\/\/([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z]))*\.([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z]))*\.(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&amp;amp;%\$#_]*)?$"&lt;/span&gt;&lt;br /&gt;                  ValidationGroup="ResellerValidation"&gt;&amp;lt;/asp:RegularExpressionValidator&gt;&lt;asp:regularexpressionvalidator id="RegularExpressionValidator2" runat="server" controltovalidate="uxRssUrl" errormessage=""&gt;"&gt;&lt;br /&gt;                 &lt;/asp:regularexpressionvalidator&gt;&lt;br /&gt;This RegularExpressionValidator will check whether the content starts with:&lt;br /&gt;(ftp:// ftps:// http:// https://) and before the next '/' comes whether there is at least 2 '.' in it.&lt;br /&gt;&lt;br /&gt;This site is helpful for RegularExpressionValidator:&lt;br /&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998267.aspx"&gt;How To: Use Regular Expressions to Constrain Input in ASP.NET&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-4954000296036657112?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/4954000296036657112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=4954000296036657112' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4954000296036657112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4954000296036657112'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/06/use-regularexpressionvalidator-to.html' title='Use RegularExpressionValidator to validate a URL / web address'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-9109245706440101598</id><published>2009-06-02T14:20:00.003+06:00</published><updated>2009-06-02T14:29:03.121+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='variable'/><title type='text'>How to check whether a variable has been declared from Javascript</title><content type='html'>Sometimes we declare javascript variables from serverside pageload method and use it in a common javascript file's method. The problem is, when that common javasript method is used by another serverside file, it might find that variable undefined. The best way to check is use typeof method of javascript. Consider the following method:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;if(typeof(uxDocumentsOrImagesRadioButton)!= 'undefined'){&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            if(document.getElementById(uxDocumentsOrImagesRadioButton)!=null){&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                var thisradioGroup = document.getElementById(uxDocumentsOrImagesRadioButton);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                if(thisradioGroup.disabled==true){        &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    thisradioGroup.disabled=false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }     &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;uxDocumentsOrImagesRadioButton variable is declared from a page's pageload method. But if another page wants to use this method before that variable has been declared, then it will throw error. So, we need to check whether the variable has been declared previously.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-9109245706440101598?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/9109245706440101598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=9109245706440101598' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9109245706440101598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9109245706440101598'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/06/how-to-check-whether-variable-has-been.html' title='How to check whether a variable has been declared from Javascript'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-348174302879792255</id><published>2009-05-11T17:31:00.007+06:00</published><updated>2009-05-11T17:56:34.026+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='IEnumerable'/><category scheme='http://www.blogger.com/atom/ns#' term='LinQ'/><title type='text'>Perform left outer join using LinQ</title><content type='html'>For my work, I had to perform a left outer join in LinQ. Here is the scenario:&lt;br /&gt;There are 2 tables:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_quJAko6OL8I/SggOcPV5KWI/AAAAAAAAAH8/JH-ya86Jnnw/s1600-h/untitled.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 201px; height: 144px;" src="http://4.bp.blogspot.com/_quJAko6OL8I/SggOcPV5KWI/AAAAAAAAAH8/JH-ya86Jnnw/s320/untitled.bmp" alt="" id="BLOGGER_PHOTO_ID_5334529636937836898" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_quJAko6OL8I/SggOt8yPj-I/AAAAAAAAAIE/1qb4fYVu7UA/s1600-h/untitled2.bmp"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 204px; height: 148px;" src="http://1.bp.blogspot.com/_quJAko6OL8I/SggOt8yPj-I/AAAAAAAAAIE/1qb4fYVu7UA/s320/untitled2.bmp" alt="" id="BLOGGER_PHOTO_ID_5334529941194117090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Auto text is the left table. Its customer column holds the Id for Customer table's elements. My task was, if there is a value in the Autotext.Customer field, then I have to show the relevant customer name. And if the value is null then it would show n\a. Only performing a left outer join can solve this. And this is how I solved it:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public IEnumerable GetAutotextsWithCustomerNameLeftJoin(int customerId)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                IEnumerable AutotextsWithCustomerName = from AutotextTable in this.Context.AutoTexts&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                                        join CustomerTable in this.Context.Customers&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                                        on AutotextTable.Customer equals CustomerTable.Id into temporaryTable&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                                        from xTable in temporaryTable.DefaultIfEmpty()                                                       &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                                        select new { AutotextTable.Id, AutotextTable.Key, AutotextTable.Value, CustomerName = xTable.Id==null?"n\a":xTable.Name };&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                return AutotextsWithCustomerName;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            catch (Exception ex)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                return null;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here, temporaryTable is the table that is created after the join operation is performed. xTable is the table that is created after left outer join is performed.&lt;br /&gt;&lt;br /&gt;This solved the problem. I took help from different online posts. But, this post helped me the most:&lt;br /&gt;&lt;a href="http://bhaidar.net/cs/archive/2007/08/01/left-outer-join-in-linq-to-sql.aspx"&gt;LEFT OUTER JOIN in LINQ To SQL&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-348174302879792255?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/348174302879792255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=348174302879792255' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/348174302879792255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/348174302879792255'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/05/make-left-outer-join-using-linq.html' title='Perform left outer join using LinQ'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_quJAko6OL8I/SggOcPV5KWI/AAAAAAAAAH8/JH-ya86Jnnw/s72-c/untitled.bmp' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-6113672679139940242</id><published>2009-03-25T14:33:00.003+06:00</published><updated>2009-03-25T15:08:24.990+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='web project'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='compile error'/><category scheme='http://www.blogger.com/atom/ns#' term='visual studio 2008'/><title type='text'>Solving compile errors: CS0006, CS0009 in Visual Studio 2008</title><content type='html'>Recently, when I was trying to run any web application project, I was getting the following error message:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;CS0006: Metadata file 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll' could not be found&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So, I searched the net for solution, and this is how I was able to solve it:&lt;br /&gt;&lt;br /&gt;First, check whether "System.EnterpriseServices.dll" file actually exists at that folder or not. You cannot navigate to the GAC_32 folder using windows explorer. You have to use command line to go there. From start menu, select 'Run' &gt; type 'cmd' press enter. then directly go there:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;cd C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;press enter. then use dir /p command to see all files in it and search for the "System.EnterpriseServices.dll" file if you cannot find it there, then again go to this location:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;cd C:\Windows\Microsoft.NET\Framework\v2.0.50727&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;press enter. From here you have to copy the file to the desired location. Use this command:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;copy System.EnterpriseServices.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now try to run that web project from visual studio, and it should work. If it doesnt work, and gives you another error: CS0009 compile error, then you have to copy all the files to that folder. First navigate to that source folder:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;cd C:\Windows\Microsoft.NET\Framework\v2.0.50727&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;press enter. Then use this command to copy all DLLs:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;copy *.dll C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You dont need to overwrite any file that already exists at the destination folder. This should solve CS0009 error.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-6113672679139940242?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/6113672679139940242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=6113672679139940242' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/6113672679139940242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/6113672679139940242'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/03/solving-compile-errors-cs0006-cs0009-in.html' title='Solving compile errors: CS0006, CS0009 in Visual Studio 2008'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-6145167495699619071</id><published>2009-03-15T12:44:00.006+06:00</published><updated>2009-03-15T14:49:20.798+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='moss 2007'/><category scheme='http://www.blogger.com/atom/ns#' term='Active Directory Users'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Login'/><category scheme='http://www.blogger.com/atom/ns#' term='emailing'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Active Directory'/><title type='text'>How to email all AD (active directory) users from sharepoint event handlers</title><content type='html'>Sharepoint is normally (or should be) installed into server PCs. And the event handler features are also installed into servers. But AD users use sharepoint from their client PCs. In this case, program fails to log into the domain if you try to retrieve information directly. Normally this code is good enough to retrive all AD users:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;ArrayList employeeEmailAddresses = new ArrayList();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;string filter = "(&amp;amp;(objectCategory=person)(objectClass=user)(sn=*))";&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                DirectorySearcher search = new DirectorySearcher(filter);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                foreach (SearchResult result in search.FindAll())&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    DirectoryEntry entry = result.GetDirectoryEntry();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    if (entry.Properties["mail"].Value != null)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        string str = entry.Properties["mail"].Value.ToString();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        employeeEmailAddresses.Add(str);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But if you are trying to get information from sharepoint event handlers using the above code block, program will throw exception at search.FindAll() :&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;COMEXCEPTION was caught: {"An operations error occurred.\r\n"}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In order to solve this, you need to manually log in the program into the AD using the credentials of an existing AD user. Then, the program can read all the informations from AD.&lt;br /&gt;&lt;br /&gt;you can use this method to get all the users from AD:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;private ArrayList getEmployeeMailAddresses()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        {          &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            ArrayList employeeEmailAddresses = new ArrayList();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                string filter = "(&amp;amp;(objectCategory=person)(objectClass=user)(sn=*))";&lt;/span&gt;&lt;br /&gt;         &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                using (DirectoryEntry root = new DirectoryEntry("LDAP://domainName","userName","password", AuthenticationTypes.Secure))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    using (DirectorySearcher searcher = new DirectorySearcher(root))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        searcher.ReferralChasing = ReferralChasingOption.All;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        searcher.SearchScope = SearchScope.Subtree;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        searcher.Filter = filter;&lt;/span&gt;&lt;br /&gt;                &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        foreach (SearchResult result in searcher.FindAll())&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                            DirectoryEntry entry = result.GetDirectoryEntry();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                            if (entry.Properties["mail"].Value != null)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                string str = entry.Properties["mail"].Value.ToString();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                                employeeEmailAddresses.Add(str);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                            }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                    }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            catch (Exception ex)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            return employeeEmailAddresses;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This line: DirectoryEntry("LDAP://domainName","userName","password", AuthenticationTypes.Secure)) will login the program into the appropriate domain, then you can get informations for all AD users. After getting the arraylist that contains all the users, you can mail all of them using this method:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;private void sendEmail(string htmlBody, ArrayList employeeEmailAddresses, string itemCreator, string subject)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            AlternateView avHtml = AlternateView.CreateAlternateViewFromString(htmlBody, null, MediaTypeNames.Text.Html);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            MailMessage m1 = new MailMessage();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            m1.AlternateViews.Add(avHtml);&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            for (int i = 0; i &amp;lt; employeeEmailAddresses.Count; i++)&lt;br /&gt;           {&lt;br /&gt;               m1.To.Add(new MailAddress(employeeEmailAddresses[i].ToString()));&lt;br /&gt;           }&lt;br /&gt;           m1.Subject = subject;&lt;/span&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&lt;/span&gt;&lt;br /&gt;    &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            SmtpClient client = new SmtpClient("smtpclientaddress");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            client.Send(m1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        }&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-6145167495699619071?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/6145167495699619071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=6145167495699619071' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/6145167495699619071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/6145167495699619071'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/03/how-to-email-all-ad-active-directory.html' title='How to email all AD (active directory) users from sharepoint event handlers'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-191440177338165554</id><published>2009-03-08T11:31:00.009+06:00</published><updated>2009-03-15T11:42:33.916+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPGroup'/><category scheme='http://www.blogger.com/atom/ns#' term='moss 2007'/><category scheme='http://www.blogger.com/atom/ns#' term='AD Group'/><category scheme='http://www.blogger.com/atom/ns#' term='SPUser'/><category scheme='http://www.blogger.com/atom/ns#' term='Domain Group'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><category scheme='http://www.blogger.com/atom/ns#' term='Active Directory'/><title type='text'>How to find a user (SPUser or domain user) belongs to a AD (active Directory) group / domain group from sharepoint</title><content type='html'>First, Lets think a set of domain users belong to a Active Directory/ domain group named $DotNet-Developers. Of course, you have added users from active directory, not from sharepoint. Now, you want to find out from sharepoint whether a user belongs to that group.  To do this, what you need to do is:&lt;br /&gt;&lt;br /&gt;1. create a sharepoint group (SPGroup) in the site, for example named DotNetSPGroup.&lt;br /&gt;2. Add the Domain group ($DotNet-Developers) inside that sharepoint Group.&lt;br /&gt;3. Give that SPGroup at least "read permission" in the site.&lt;br /&gt;4. Search for user under that SPGroup using group.ContainsCurrentUser method.&lt;br /&gt;&lt;br /&gt;Now, while running any specific program, you want to find out whether a specific user belongs to that active directory group or not. Lets think, you are getting the user from a "Person or group field" from sharepoint. &lt;a href="http://cosmicice.blogspot.com/2008/12/retrieve-user-name-from-sharepoints.html"&gt;Now retrieve the SPUser from that field&lt;/a&gt;. after that just use this method:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;private bool IsUserInGroup(SPUser targetUser, SPItemEventProperties properties, string groupName)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            bool containsUser=false;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            using(SPSite targerSite= new SPSite(properties.SiteId,targetUser.UserToken))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                SPWeb targetWeb=targerSite.OpenWeb(properties.RelativeWebUrl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                                   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        SPGroupCollection LMSGroups = properties.OpenWeb().Groups;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                            SPGroup groupForDotNetDev = LMSGroups[groupName];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                            if (groupForDotNetDev.ContainsCurrentUser)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                            {                              &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                              containsUser=true;                                                      &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                            }                            &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        catch (Exception e)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                        }           &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;            return containsUser;            &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This should do the trick.&lt;br /&gt;&lt;br /&gt;using(SPSite targerSite= new SPSite(properties.SiteId,targetUser.UserToken)) changes the current user to that user. Then, you can use groupName.ContainsCurrentUser user method to check whether the user is inside that group or not. This method even searches inside AD groups, if that AD group is added inside an SPGroup. So, it works just fine.&lt;br /&gt;&lt;br /&gt;&lt;a style="color: rgb(255, 102, 0);" href="http://chrissyblanco.blogspot.com/2007/07/determining-whether-user-is-member-of.html"&gt;I must thank El Blanco for his post.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-191440177338165554?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/191440177338165554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=191440177338165554' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/191440177338165554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/191440177338165554'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/03/how-to-find-user-spuser-or-domain-user.html' title='How to find a user (SPUser or domain user) belongs to a AD (active Directory) group / domain group from sharepoint'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-3259453797508244551</id><published>2009-02-11T13:17:00.014+06:00</published><updated>2009-02-11T16:51:17.448+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPRoleAssignmentCollection'/><category scheme='http://www.blogger.com/atom/ns#' term='moss 2007'/><category scheme='http://www.blogger.com/atom/ns#' term='SPRoleAssignment'/><category scheme='http://www.blogger.com/atom/ns#' term='Event Handlers'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='SPRoleDefinition'/><category scheme='http://www.blogger.com/atom/ns#' term='RunWithElevatedPrivileges'/><category scheme='http://www.blogger.com/atom/ns#' term='Sharepoint Permission'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><title type='text'>Create or update an SPListitem in an SPList from event handlers where current user has read (or no) permission</title><content type='html'>Scenario: User is adding/updating/deleting an item in a list (listX), where he has adequate permission. But as soon as he does it, I have to change the content of an item which belongs to a list (listY), where he has read permission only (also works if he has no permission at all) . This is how I did it:&lt;br /&gt;&lt;br /&gt;In the event handler of listX, add this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;public override void ItemAdded(SPItemEventProperties properties)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         if (properties.ListTitle != "listX")&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             return;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         breakListPermission(properties, "listY");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         //add new item, or update, or delete an existing item in "listY"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         restoreListPermission(properties, "listY");&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Here is the method for changing list permission to give current user adequate permission:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;private void breakListPermission(SPItemEventProperties properties, string strTargetList)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         base.ItemAdded(properties);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         this.DisableEventFiring();        &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         SPSecurity.RunWithElevatedPrivileges(delegate()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             using (SPSite targetSite = new SPSite(properties.OpenWeb().Site.ID))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPWeb targetWeb = targetSite.OpenWeb(properties.RelativeWebUrl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 targetWeb.AllowUnsafeUpdates = true;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 targetWeb.Update();               &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPList targetList = targetWeb.Lists[strTargetList];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                  SPRoleDefinition adminRoleDefinition = targetWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 if (!targetList.HasUniqueRoleAssignments)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                      SPRoleAssignmentCollection targetWebRoleCollections = targetWeb.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignment targetWebRole = targetWebRoleCollections[2];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     if(!targetWebRole.RoleDefinitionBindings.Contains(adminRoleDefinition))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                         targetWebRole.RoleDefinitionBindings.Add(adminRoleDefinition);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                         targetWebRole.Update();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 else{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignmentCollection myRoleCollection = targetList.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignment currentRoleAssignment = myRoleCollection[2];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     if (!currentRoleAssignment.RoleDefinitionBindings.Contains(adminRoleDefinition))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                          currentRoleAssignment.RoleDefinitionBindings.Add(adminRoleDefinition);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                          currentRoleAssignment.Update();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     }                    &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 }                &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;     );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;First of all, It is really important to declare new SPSite, SPWeb... objects inside the RunWithElevatedPrivileges block. If you use the objects that you declared earlier, simply wont work.&lt;br /&gt;Then you need to update the website to allow unsafe updates by this code:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;targetWeb.AllowUnsafeUpdates = true;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;targetWeb.Update();               &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;otherwise, you will get exception like this:&lt;br /&gt;"&lt;span style="color: rgb(255, 102, 0);"&gt;The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.&lt;/span&gt;"&lt;br /&gt;Next you need to check whether "listY: inherit permission that has been assigned to the website or not. If it inherits the website's permission, then you have to change the permission for the website, otherwise you have to change the permission for the list. Use this line to check it:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;if (!targetList.HasUniqueRoleAssignments){&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can also break the inheritence, and create new roleassignments for current list:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;targetList.BreakRoleInheritance(false);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For my work, it was good enough just to change the permission of the web. Since, the list inherits permission from the web.&lt;br /&gt;I have used this block to retrieve the SPRoleAssignment relevant to current user:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignmentCollection myRoleCollection = targetList.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignment currentRoleAssignment = myRoleCollection[2];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I have used hardcode here, because I knew that the 3rd roleassignment of both site and "listY" would be the roleassignment that contains current user. If you dont know where the current user is, then you have to do this:&lt;br /&gt;(&lt;span style="color: rgb(0, 0, 0);"&gt;You must run this following code block before the RunWithElevatedPrivileges starts. When the process enters RunWithElevatedPrivileges code block, the current user will change into "System Account"&lt;/span&gt;.)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPGroupCollection lmsGroups = targetWeb.Groups; //this targetWeb was initiated before RunWithElevatedPrivileges&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPGroup lmsMember = lmsGroups[0]; //just initiate&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 foreach (SPGroup spgroup in lmsGroups)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     if (spgroup.ContainsCurrentUser)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                         lmsMember = spgroup;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(Run this following block inside the RunWithElevatedPrivileges:)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignmentCollection myRoleCollection = targetList.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignment currentRoleAssignment = myRoleCollection.GetAssignmentByPrincipal((SPPrincipal)lmsMember);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the current user/ group doesn't belong to that list, then you have to create, and add it with the list. then you have to give them permission by using SPRoleDefinition. If you try to give them permission before you add it to the list you will get exception (at least, I got the exception):&lt;br /&gt;"&lt;span style="color: rgb(255, 102, 0);"&gt;Cannot update a permission level assignment that is not part of a permission level assignment collection.&lt;/span&gt;"&lt;br /&gt;Here's how (&lt;span style="color: rgb(0, 0, 0);"&gt;they should belong to the web, at least.. or this wont work&lt;/span&gt;):&lt;br /&gt;&lt;br /&gt;get the group where the user belongs before the RunWithElevatedPrivileges block, or create a single user SPRoleAssignment:&lt;br /&gt;(for user:)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignment currentRoleAssignment = new SPRoleAssignment(targetWeb.CurrentUser.LoginName, targetWeb.CurrentUser.Email, targetWeb.CurrentUser.Name, targetWeb.CurrentUser.Notes);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;(for group, after getting the group:)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleAssignment currentRoleAssignment = new SPRoleAssignment((SPPrincipal)lmsMember);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now inside the RunWithElevatedPrivileges block do this:&lt;br /&gt;you should check the value for &lt;span style="color: rgb(102, 51, 255);"&gt;currentRoleAssignment.Parent&lt;/span&gt; . If it is null, and you add a roledefinition with it, and update the roleassignment, then surely you will heat the preceeding exception when executing: &lt;span style="color: rgb(102, 51, 255);"&gt;currentRoleAssignment.Update(); &lt;span style="color: rgb(0, 0, 0);"&gt;line&lt;/span&gt;&lt;/span&gt;. But if &lt;span style="color: rgb(102, 51, 255);"&gt;currentRoleAssignment.Parent &lt;span style="color: rgb(0, 0, 0);"&gt;is not null, and its value is equal to either the list name, or the web name, then its ok to add a roledefinition with it.&lt;/span&gt; &lt;/span&gt;Else, you need to associate it with the list first:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;targetList.RoleAssignments.Add(currentRoleAssignment);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;targetList.Update();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If the adding is successful, then retrieve this new roleassignment from role assignment collection:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;currentRoleAssignment= targetList.RoleAssignments[targetList.RoleAssignments.Count - 1];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And give roledefinition (permission) according to this way:&lt;br /&gt;             &lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;SPRoleDefinition adminRoleDefinition = targetWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;if (!currentRoleAssignment.RoleDefinitionBindings.Contains(adminRoleDefinition))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;      currentRoleAssignment.RoleDefinitionBindings.Add(adminRoleDefinition);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;      currentRoleAssignment.Update();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That should do the trick. And when removing permission, just do the opposite:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;private void restoreListPermission(SPItemEventProperties properties, string strTargetList)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         SPSecurity.RunWithElevatedPrivileges(delegate()&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             using (SPSite targetSite = new SPSite(properties.OpenWeb().Site.ID))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPWeb targetWeb = targetSite.OpenWeb(properties.RelativeWebUrl);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPList targetList = targetWeb.Lists[strTargetList];             &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 SPRoleDefinition adminRoleDefinition = targetWeb.RoleDefinitions.GetByType(SPRoleType.Administrator);                &lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 if (!targetList.HasUniqueRoleAssignments)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 {&lt;/span&gt;&lt;br /&gt;      &lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignmentCollection targetWebRoleCollections = targetWeb.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignment targetWebRole = targetWebRoleCollections[2];&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     if (targetWebRole.RoleDefinitionBindings.Contains(adminRoleDefinition))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                         targetWebRole.RoleDefinitionBindings.Remove(adminRoleDefinition);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                         targetWebRole.Update();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 else{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignmentCollection myRoleCollection = targetList.RoleAssignments;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     SPRoleAssignment currentRoleAssignment = myRoleCollection[2];&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     if (currentRoleAssignment.RoleDefinitionBindings.Contains(adminRoleDefinition))&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                          currentRoleAssignment.RoleDefinitionBindings.Remove(adminRoleDefinition);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                          currentRoleAssignment.Update();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                     }                   &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 }               &lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 targetWeb.AllowUnsafeUpdates = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;                 targetWeb.Update();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;             }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         );&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;         this.EnableEventFiring();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;     }&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;There you go. It did the job for me. Hope it might help you too. But Sharepoint is so unpredictable sometimes.&lt;span style="color: rgb(0, 0, 0);"&gt;.. I don't promise anything.. :)&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-3259453797508244551?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/3259453797508244551/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=3259453797508244551' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3259453797508244551'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3259453797508244551'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/02/create-or-update-splistitem-in-splist.html' title='Create or update an SPListitem in an SPList from event handlers where current user has read (or no) permission'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-8699215115001638198</id><published>2009-01-20T17:17:00.005+06:00</published><updated>2009-01-20T17:54:37.318+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Attaching database'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='unicode'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL query'/><category scheme='http://www.blogger.com/atom/ns#' term='SQL server 2005'/><title type='text'>Attaching a database without (.ldf) file</title><content type='html'>If you don't have the log (.ldf) file for an SQL server database, and you need to attach the database into sql server 2005, then run this sql query from SQL server 2005:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;sp_attach_single_file_db N'OMS', N'E:\DataBase\OMS.mdf'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The first part is the name of the database and the second part is the physical address of the (.mdf) file. "N" prefix represents National Language Character Set. Which means the subsequent string is in unicode.&lt;br /&gt;&lt;br /&gt;Alternatively, you can directly add a Database into a visual studio project. For this, you need to add an entry in the app.config file:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&amp;lt;add name="WpfDataEntry.Properties.Settings.OMSConnectionString"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;connectionString="Data Source=.\SQLEXPRESS;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;AttachDbFilename=|DataDirectory|\OMS.mdf;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;Integrated Security=True;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;User Instance=True"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;providerName="System.Data.SqlClient" /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The |Datadirectory| is a variable which holds the location of the root folder for databases. For ASP .NET web applications, the name of the folder is App_data. for desktop applications, the folder is the "Bin" folder&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 102, 0);"&gt;Credit for this post goes to Tanveer vai (Tanveer Ibn Haresh, Software Engineer, Bording Vista Ltd.)&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-8699215115001638198?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/8699215115001638198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=8699215115001638198' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/8699215115001638198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/8699215115001638198'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/01/adding-database-without-ldf-file.html' title='Attaching a database without (.ldf) file'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-4747750640495864504</id><published>2009-01-20T10:25:00.008+06:00</published><updated>2009-01-20T12:37:56.717+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='endedit'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraWebTree'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraTree'/><category scheme='http://www.blogger.com/atom/ns#' term='Infragestics'/><category scheme='http://www.blogger.com/atom/ns#' term='keycode'/><category scheme='http://www.blogger.com/atom/ns#' term='keydown'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='escape characters'/><category scheme='http://www.blogger.com/atom/ns#' term='editkeydown'/><title type='text'>While editing an ultrawebtree node, stop users to input escape characters</title><content type='html'>In order to stop users, from giving input of escape characters, you have to handle the editkeydown client side event. in the designer file inside the client side events add this:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;EditKeyDown="UltraWebTree1_EditKeyDown"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In the javascript file add this function:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;function UltraWebTree1_EditKeyDown(treeId, nodeId, keycode) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;    if (keycode == 220) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        var treeInstance = igtree_getTreeById(UltraWebTreeClientID)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        treeInstance.endEdit(false);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;    }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;when the user presses "\" then the value of keycode becomes 220. endEdit(false) ends the editing process of a node, and goes back to the text that was there before editing began. endEdit(true) stops the editing but keeps the updated text that was while the tree node was being edited. So, its always a good idea to use endEdit(false) method. UltraWebTreeClientID was passed from the server side.&lt;br /&gt;&lt;br /&gt;If you need to block user from pressing other keys too, then debug the process and get the value of keycode for corresponding characters, then add those values in the if condition.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-4747750640495864504?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/4747750640495864504/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=4747750640495864504' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4747750640495864504'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4747750640495864504'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/01/while-editing-ultrawebtree-node-stop.html' title='While editing an ultrawebtree node, stop users to input escape characters'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-3431422859565608206</id><published>2009-01-18T17:16:00.004+06:00</published><updated>2009-01-20T12:41:21.594+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='site restore'/><category scheme='http://www.blogger.com/atom/ns#' term='site backup'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='transfer sharepoint feature'/><category scheme='http://www.blogger.com/atom/ns#' term='feature'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><title type='text'>Backup and Restore a sharepoint site from 1 pc to another with installed features</title><content type='html'>In order to backup and restore a sharePoint site say from pc1 to pc2 using command prompt, First open the command prompt in pc1:&lt;br /&gt;start... Run... type cmd... press enter&lt;br /&gt;&lt;br /&gt;In the command prompt, type:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN&lt;/span&gt;&lt;br /&gt;...press enter&lt;br /&gt;&lt;br /&gt;Then run this command to take backup of an existing site:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;stsadm -o backup -url http://svradm002:11226/ -filename c:\backUpSite.dat -overwrite&lt;/span&gt;&lt;br /&gt;replace the url and file location with the data you need&lt;br /&gt;&lt;br /&gt;In Pc2, copy and paste the backupSite.dat file to any location (ex: in c drive). Open command prompt and go to the bin folder in preceding way. Then use this command to restore from a backup to an existing site. Remember, you have to create the site on the following location (http://vpc-wss:30322/) first, then you can restore from the dat file on  that site. (Assume that the address of our target site is: http://vpc-wss:30322/)&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;stsadm -o restore -url http://vpc-wss:30322/ -filename c:\backupSite.dat -overwrite&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;U will find that the feature is not available with the new site that you created. If you added the feature manually, by creating feature folder, element &amp;amp; manifest file then you have to do again in the new PC. &lt;a href="http://cosmicice.blogspot.com/2008/12/create-new-sharepoint-feature-add.html"&gt;Check my previous blog post&lt;/a&gt;. But if you created a feature using Visual Studio with vsewss (visual studio extension for windows sharePoint server) installed, then you have to do this:&lt;br /&gt;-In PC1, open the project folder&lt;br /&gt;-copy the debug folder&lt;br /&gt;-paste it anywhere in pc2&lt;br /&gt;-then edit the setup.bat file inside the debug folder. replace old addresses http://localhost:11226/ with new one: http://localhost:30322/&lt;br /&gt;-then run the setup.bat file.&lt;br /&gt;this will add the feature in the new site.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-3431422859565608206?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/3431422859565608206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=3431422859565608206' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3431422859565608206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3431422859565608206'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/01/backup-and-restore-sharepoint-site-from.html' title='Backup and Restore a sharepoint site from 1 pc to another with installed features'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-4834963916199298411</id><published>2009-01-12T15:12:00.007+06:00</published><updated>2009-01-20T12:42:22.060+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraWebTree'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraTree'/><category scheme='http://www.blogger.com/atom/ns#' term='Deligate'/><category scheme='http://www.blogger.com/atom/ns#' term='Infragestics'/><category scheme='http://www.blogger.com/atom/ns#' term='client side scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='ASP .net'/><category scheme='http://www.blogger.com/atom/ns#' term='server side scripting'/><title type='text'>Use a single event to traverse back and forth between server-side and client-side 2 times to complete a task</title><content type='html'>I placed a UltraWebTree in a Usercontrol(.ascx) file, and used a (.cs) file to handle event and logic. Then, reference a Javascript where I handled the client side events. I had to add a new node to a tree from client-side, rename it, add it into the database from server-side, then select it from the client side, and go back to server side to open folder associated with that new node. I did these in 4 steps:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step1. Create a new node from client side, rename it:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add this code into the Javascript file to add a new node:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;var currentNodeId;&lt;br /&gt;var newNodeAdded = false;&lt;br /&gt;var newNodeId;&lt;br /&gt;&lt;br /&gt;function addChild() {&lt;br /&gt;var tree = igtree_getTreeById(UltraWebTreeClientID);&lt;br /&gt;var node = tree.getNodeById(currentNodeId);&lt;br /&gt;if (node.hasChildren()) {&lt;br /&gt;if (node.getExpanded() == false) {&lt;br /&gt;node.setExpanded(true);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;if (node) {&lt;br /&gt;newnode = node.addChild(newFolderName);&lt;br /&gt;newNodeId = newnode.Id;&lt;br /&gt;newnode.edit();&lt;br /&gt;newNodeAdded = true;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;CurrentNodeID is the id of the node that is currently selected taken from the nodeSelectionChanged mathod. UltraWebTreeClientID is the id of the tree that was passed from the (.cs) file's pageLoad section's If(!Page.isPostback) portion:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;String Script = "var UltraWebTreeClientID = '" + UltraWebTree1.ClientID.Replace("_", "") + "';";&lt;br /&gt;this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "InitVariable", Script, true);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step2: Go back to server-side to add a record into the DB:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After a new node has been added, the nodeAdded event will be fired, which you need to handle:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;void UltraWebTree1_NodeAdded(object sender, Infragistics.WebUI.UltraWebNavigator.WebTreeNodeEventArgs e)&lt;br /&gt;if (uxTreeEventLog.Text == "")&lt;br /&gt;{&lt;br /&gt;TreeNodeChangedArgs args = new TreeNodeChangedArgs();&lt;br /&gt;args.Name = e.Node.Text;&lt;br /&gt;args.Parent = e.Node.Parent.Tag.ToString();&lt;br /&gt;args.TreeNodeAction = TreeNodeChangeAction.Added;&lt;br /&gt;if (TreeNodeChanged != null)&lt;br /&gt;TreeNodeChanged(sender, args);&lt;br /&gt;e.Node.DataKey = Convert.ToInt32(args.ID);&lt;br /&gt;e.Node.Tag = Convert.ToInt32(args.ID);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;TreeNodeChangedArgs is a class declared globally to handle the event properties:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public class TreeNodeChangedArgs&lt;br /&gt;{&lt;br /&gt;public String ID;&lt;br /&gt;public String Name;&lt;br /&gt;public String Parent;&lt;br /&gt;public TreeNodeChangeAction TreeNodeAction;&lt;br /&gt;public Boolean Cancel;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;TreeNodeChangedAction is an enum declared globally:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public enum TreeNodeChangeAction&lt;br /&gt;{&lt;br /&gt;Added,&lt;br /&gt;Changed,&lt;br /&gt;Removed&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;TreeNodeChange is a variable of a deligate also declared globally:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public delegate void TreeNodeChangedEventHandler(object sender, TreeNodeChangedArgs e);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public TreeNodeChangedEventHandler TreeNodeChanged;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;It will take the event outside the usercontrol and let you handle the event from the page where you have placed this usercontrol. There you will add a new record using Business Layer in the DB taking info of the node (ex: id, name, parent, etc...) that was passed from here.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step 3: Go back to client-side to select the node:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To go back to client-side again, you need to use end request method from the (.cs) file's pageLoad section's If(!Page.isPostback) portion:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;this.Page.ClientScript.RegisterStartupScript(this.GetType(), "RegisterFunciton", "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(TreeControl_EndRequestHandler);", true);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Now, you need to write a function in the javascript file with the name TreeControl_EndRequestHandler:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;function TreeControl_EndRequestHandler(sender, args) {&lt;br /&gt;if (newNodeAdded == true) {&lt;br /&gt;var tree = igtree_getTreeById(UltraWebTreeClientID);&lt;br /&gt;var node = tree.getNodeById(newNodeId);&lt;br /&gt;node.setSelected(true);&lt;br /&gt;newNodeAdded = false;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step 4: Open associated folder from server-side:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After selecting the new node from the client-side, the selectionChanged event will be fired which you have to handle in the (.cs) file:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;void UltraWebTree1_NodeSelectionChanged(object sender, WebTreeNodeEventArgs e)&lt;br /&gt;{&lt;br /&gt;if (NodeClicked != null)&lt;br /&gt;NodeClicked(sender, e);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Again, NodeClicked is a variable of a delicate that was declared globally:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;public delegate void NodeClickedEventHandler(object sender, WebTreeNodeEventArgs e);&lt;br /&gt;public NodeClickedEventHandler NodeClicked;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;You can take the event outside of this control and handle it on the page, where you can search for associate folder in the DB, and open it (in a different panel beside to the tree)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;span style="font-weight: bold;"&gt;Step 5: Create chain effect:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have a debugging point set at the TreeControl_EndRequestHandler function, then you will notice that the process has come back to client-side again. In fact, after every server-side events, process will come back to here, from where you can chain it back to server side again.&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 153, 102);"&gt;Most part of this code(server-side part) was done by Ranku vai (Anupam Ranku, Senior Software Engineer, Bording Vista Ltd.) Thank you very much, Ranku vai.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-4834963916199298411?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/4834963916199298411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=4834963916199298411' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4834963916199298411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4834963916199298411'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/01/use-single-event-to-traverse-back-and.html' title='Use a single event to traverse back and forth between server-side and client-side 2 times to complete a task'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-2129807783989422532</id><published>2009-01-12T09:56:00.009+06:00</published><updated>2009-03-08T12:26:04.896+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='javascript'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraWebTree'/><category scheme='http://www.blogger.com/atom/ns#' term='UltraTree'/><category scheme='http://www.blogger.com/atom/ns#' term='checkbox'/><category scheme='http://www.blogger.com/atom/ns#' term='node'/><category scheme='http://www.blogger.com/atom/ns#' term='Infragestics'/><category scheme='http://www.blogger.com/atom/ns#' term='node unchecked'/><category scheme='http://www.blogger.com/atom/ns#' term='unchecked'/><title type='text'>Check whether all the checkboxes of a tree are unchecked from client side (Javascript)</title><content type='html'>We are using infragestics for our develpment. so we had to use the UltraWebTree provided by infragestics. Add this code in client side:&lt;br /&gt;&lt;br /&gt;First, declare a global varriable:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;var allUnchecked = true;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;This part of the code should be written inside a javascript function where u will handle the event. For my work, I used the event handling of UltraWebMenu.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;function ultraMenu1_itemClicked(MenuId, ItemId) {&lt;br /&gt;if (ItemId == UltraWebMenuClientID + "_4") {&lt;br /&gt;var treeInstance = igtree_getTreeById(UltraWebTreeClientID);&lt;br /&gt;var testNodes = treeInstance.getNodes();&lt;br /&gt;allUnchecked = true;&lt;br /&gt;checkNodes(testNodes);&lt;br /&gt;if (allUnchecked == true) {&lt;br /&gt;    alert('All are unchecked');&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;UltraWebTreeClienID holds the client id of infragestics ultrawebtree that was passed from the server side (a .cs code behind file where the ultrawebtree has been placed) in following way:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;String Script = "var UltraWebTreeClientID = '" + UltraWebTree1.ClientID.Replace("_", "") + "';";&lt;br /&gt;this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "InitVariable", Script, true);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;br /&gt;UltraWebMenuClientID was passed from that .cs file in the same way, and _4 checks whether the 4th item of the ultrawebmenu is clicked.&lt;br /&gt;checknodes is the function that checks all the nodes whether they are checked or not. Place it anywhere in the javascript file:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;function checkNodes(testNodes){&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;    for (var i = 0; i &amp;lt; testNodes.length; i++) {&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        if (testNodes[i].getChecked() == true) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            allUnchecked = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        }&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        if (testNodes[i].hasChildren() == true) {&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;            checkNodes(testNodes[i].getChildNodes())&lt;/span&gt;&lt;br /&gt;           &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;        }&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;    }&lt;/span&gt;&lt;br /&gt;   &lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After running checknodes recursively for all the nodes, it will go back to the main function and will show the alert if all nodes are unchecked.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-2129807783989422532?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/2129807783989422532/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=2129807783989422532' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/2129807783989422532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/2129807783989422532'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2009/01/check-whether-all-checkboxes-of-tree.html' title='Check whether all the checkboxes of a tree are unchecked from client side (Javascript)'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-3007177835555844023</id><published>2008-12-31T15:39:00.005+06:00</published><updated>2009-01-13T17:43:29.614+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='task list'/><category scheme='http://www.blogger.com/atom/ns#' term='moss 2007'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='change status'/><category scheme='http://www.blogger.com/atom/ns#' term='feature'/><category scheme='http://www.blogger.com/atom/ns#' term='activate feature'/><category scheme='http://www.blogger.com/atom/ns#' term='drop down menu'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><title type='text'>Create a new sharepoint feature: Add a custom action to Task list item's drop down menu.</title><content type='html'>Normally, when we click on a sharepoint list item, from the drop down menu we can see: "View item, Edit item, Manage properties, Delete Item..." Lets see how can we add a new item to this drop down menu...&lt;br /&gt;&lt;br /&gt;For my work, I need to add a custom action named "Change Status" to change the status of a Task list item. So, I modified the "EditForm.aspx" and created a new form named "ApproveStatus3.aspx" by using sharepoint designer. This page only edits the Status field of that item. Then I followed these steps:&lt;br /&gt;&lt;br /&gt;1. Create a new folder, called "ChangeStatus", in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES&lt;br /&gt;2. Create an empty Xml file, called "feature.xml" in the "ChangeStatus" folder or you can copy and paste the same "feature.xml" file from other feature folder&lt;br /&gt;3. Empty the feature.xml file and add the following content&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;br /&gt;&amp;lt;Feature Title="Change Status"&lt;br /&gt;Description="Changes only the status of the leave letter."&lt;br /&gt;Scope="Site"&lt;br /&gt;Id="C0B8CB6D-6DD9-4c89-A1DC-E97A4745875C" xmlns="&lt;a href="http://schemas.microsoft.com/sharepoint/"&gt;http://schemas.microsoft.com/sharepoint/&lt;/a&gt;"&gt;&lt;br /&gt;&amp;lt;ElementManifests&gt;&lt;br /&gt;&amp;lt;ElementManifest Location="Elements.xml" /&gt;&lt;br /&gt;&amp;lt;/ElementManifests&gt;&lt;br /&gt;&amp;lt;/Feature&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;4. Create an empty Xml file, called "Elements.xml" in the "ChangeStatus" folder or you can copy and paste the same "feature.xml" file from other feature folder&lt;br /&gt;5. Empty the file and add the following content &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;&lt;elements xmlns="http://schemas.micræsoft.com/sharepoint/"&gt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;br /&gt;&lt;customaction id="ApprovalList.ChangeStatus" registrationtype="List"&gt;&amp;lt;Elements xmlns="&lt;a href="http://schemas.microsoft.com/sharepoint/"&gt;http://schemas.microsoft.com/sharepoint/&lt;/a&gt;"&gt; &lt;/customaction&gt;&lt;/elements&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;CustomAction Id="ApprovalList.ChangeStatus"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;RegistrationType="List"&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;RegistrationId="107"&lt;br /&gt;Location="EditControlBlock" &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;Sequence="100"&lt;br /&gt;Title="Change Status"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;ImageUrl="/_layouts/images/TaskPane.gif"&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;UrlAction Url="&lt;a href="http://svradm002:11226/lms/Lists/ApprovalList/ApproveStatus3.aspx?ID=%7BItemId%7D&amp;amp;Source=http%3A%2F%2Fsvradm002%3A11226%2Flms%2FLists%2FApprovalList%2FMyItems%2Easpx"&gt;http://svradm002:11226/lms/Lists/ApprovalList/ApproveStatus3.aspx?ID={ItemId}&amp;amp;Source=http%3A%2F%2Fsvradm002%3A11226%2Flms%2FLists%2FApprovalList%2FMyItems%2Easpx&lt;/a&gt;" /&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;/CustomAction&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&amp;lt;/Elements&gt;&lt;span style="color: rgb(102, 51, 255);"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;6. Run command prompt, and nevigate to sharepoint's BIN folder... cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN Press enter.&lt;br /&gt;7. Install the new feature by running the following command:&lt;br /&gt;Stsadm –o installfeature –name changestatus&lt;br /&gt;8. Activate the new feature by running the following command:&lt;br /&gt;Stsadm –o activatefeature -name changestatus -url&lt;/span&gt; &lt;a href="http://svradm002:11226/lms/" mce_href="http://siteurl/"&gt;http://svradm002:11226/lms/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;Here, registration id="107" menas this feature will be added with the drop down menu for items in task lists.&lt;br /&gt;&lt;br /&gt;sequence="100" will probably place this item at the top most position of the drop down list. Increase the sequence number if you want to place it somewhere below.&lt;br /&gt;&lt;br /&gt;in the url section,&lt;/span&gt; &lt;a id="'{ItemId}&amp;amp;Source=" href="http://svradm002:11226/lms/Lists/ApprovalList/ApproveStatus3.aspx?"&gt;http://svradm002:11226/lms/Lists/ApprovalList/ApproveStatus3.aspx?&lt;/a&gt; &lt;span style="color: rgb(0, 0, 0);"&gt;is the location where I saved my custorm editing form. ID={ItemId} passes the current item that has been clicked on.&lt;/span&gt; &lt;span style="color: rgb(51, 51, 255);"&gt;&lt;u&gt;Source=http%3A%2F%2Fsvradm002%3A11226%2Flms%2FLists%2FApprovalList%2FMyItems%2Easpx &lt;/u&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;holds the return address when the editing will be done. normally you can pass the address for "allitems.aspx" page from the browser's address box.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;span style="color: rgb(102, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-3007177835555844023?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/3007177835555844023/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=3007177835555844023' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3007177835555844023'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/3007177835555844023'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2008/12/create-new-sharepoint-feature-add.html' title='Create a new sharepoint feature: Add a custom action to Task list item&apos;s drop down menu.'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-9128251138072391739</id><published>2008-12-04T10:15:00.003+06:00</published><updated>2009-03-08T12:09:27.274+06:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='moss 2007'/><category scheme='http://www.blogger.com/atom/ns#' term='person or group field'/><category scheme='http://www.blogger.com/atom/ns#' term='sharepoint'/><category scheme='http://www.blogger.com/atom/ns#' term='spfielduservalue'/><category scheme='http://www.blogger.com/atom/ns#' term='spfielduser'/><category scheme='http://www.blogger.com/atom/ns#' term='wss 3.0'/><title type='text'>Retrieve the user name from a sharepoint's "Person or Group" field.</title><content type='html'>Previously, in VPC, to get a name from a "person or group" field from a sharepoint list I had to use this code (in C#):&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;string onBehalfOf = properties.AfterProperties["On_x0020_Behalf_x0020_Of"].ToString();&lt;br /&gt;int startingIndex = onBehalfOf.IndexOf("#") + 1;&lt;br /&gt;int endingIndex = onBehalfOf.Length - 4;&lt;br /&gt;string onBehalfName = onBehalfOf.Substring(startingIndex, endingIndex);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;and I got the name. "On_x0020_Behalf_x0020_Of" is the column (field) name of a sharepoint list&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;"OnBehalfof" string gets value like this: "11;#M. Andalibur Rahman". So, by doing a substring by "#" u can get the name portion. But in the virtual Server, the "OnBehalOf" string gets only the number, "11", and the program crashes when it wants to do the substring operation. So, I had to figure out the solution by spending almost 1 day. And the solution is:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;string currentValue= properties.AfterProperties["On_x0020_Behalf_x0020_Of"].ToString();&lt;br /&gt;SPFieldUser userField= (SPFieldUser)properties.OpenWeb().Lists[properties.ListTitle].Fields.GetField ("On_x0020_Behalf_x0020_Of");&lt;br /&gt;SPFieldUserValue fieldValue= (SPFieldUserValue)userField.GetFieldValue(currentValue);&lt;br /&gt;string onBehalfName = fieldValue.User.Name;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;&lt;br /&gt;&lt;/span&gt;U got the user name.&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;fieldValue.User&lt;/span&gt; will give you SPUser object&lt;br /&gt;&lt;span style="color: rgb(102, 102, 204);"&gt;fieldValue.User.Id&lt;/span&gt; will give you the user Id, 11&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-9128251138072391739?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/9128251138072391739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=9128251138072391739' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9128251138072391739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/9128251138072391739'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2008/12/retrieve-user-name-from-sharepoints.html' title='Retrieve the user name from a sharepoint&apos;s &quot;Person or Group&quot; field.'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4826856543136883832.post-4677879120238373406</id><published>2008-12-03T16:01:00.000+06:00</published><updated>2008-12-03T16:03:24.130+06:00</updated><title type='text'>Just joined...</title><content type='html'>"Helo world!"&lt;br /&gt;Just joined blogspot... dont know why. hoping to have some good time here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4826856543136883832-4677879120238373406?l=cosmicice.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cosmicice.blogspot.com/feeds/4677879120238373406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4826856543136883832&amp;postID=4677879120238373406' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4677879120238373406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4826856543136883832/posts/default/4677879120238373406'/><link rel='alternate' type='text/html' href='http://cosmicice.blogspot.com/2008/12/just-joined.html' title='Just joined...'/><author><name>cosmicice</name><uri>http://www.blogger.com/profile/17538162362234880883</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
