Thursday, August 26, 2010

Infopath form cannot save the following form - Form is Read Only

I have created the infopath project in Visual Studio and deploying into SharePoint environment. After some days, I got to change the infopath form to match the new requirement and redeploy to the SharePoint environment. I have opened the Visual Studio and spent half an hour to edit all the changes and tried to save the form. But, while saving it was started giving me the alert message that "The infopath form cannot save the following form: Template Name is ready only." I did not understand and check all file properties of the manifest.xsf and unchecked the checkbox read only. Still it was giving me the same error message. The error message was completely confused me and no any other clue. So, started searching in internet for the solution and after searched about an hour, found the information. If you have opened the infopath form, then close it. [No other way, you will lose all changes you have made.]

  1. Open the manifest.xsf in notepad.
  2. PublishUrl: Search for "publishurl". I believe, this pointed to the old location other than what actual the form is submitted to. Make it empty [No problem].
  3. runtimeCompatibilityURL: in the notepad, search again for "runtimeCompatibilityURL". Now change its value to "http://sharepointserver/_vti_bin/FormsServices.asmx". 
  4. If you are using the source control like VSS, Source vault, TFS or whatever then you have to do below things.
  • Open Visual Studio and checkout all the files in the Infopath Form Template folder.
  • Once all checked out, then close the Visual Studio and reopen.
    Note: replace sharepointserver in above url with your sharepoint server name.

    Check for more information here. MSDN
    That's it. Now, you have to reopen the file and do whatever changes you have to do. Enjoy.

    Monday, August 23, 2010

    How to get the files from GAC in Windows

    This is what I think about since I started working on Windows. I don't know how to see the Windows GAC files and get them for other use. For example, sometimes I deploy the files to GAC location and then want to move the same dll to some other server. But, as usual, the original files missed from the file system. The only location I can get them is GAC. But, don't know how to get the files from GAC. This is a big question and resolved my my colleague Phani recently. I was surprised and felt very happy after the resolution he found and now I am utilizing it very efficiently.
    There is a command available in Windows for doing the task. "subst".

    The command will create a virtual folder of all GAC files to a separate drive. Below is the syntax:
    subst Z: C:\windows\Assembly
    When you go to the my computer you will find a new drive under the regular drives. Just go inside and you can see all the GAC files. The folder GAC_MSIL is what your all files reside in. Copy the dll's you needed and paste them in some safe location for backup.

    To remove the Z drive from machine, then use below command.
    subst Z: /D
    All credits goes to Phani and take a look at this post from him for more information. Enjoy some nice tips and rare findings from the blog.

    Check drop down list contains a value in c#

    This is again a very simple post and want to share. I have seen many people write good coding, but, sometimes they don't pick efficient way to do somethings. When we do code reviews we can identify some code parts are very simple to implement but they implement it in complex way, want to correct them. A simple scenario is, how to check a drop down contains a value. Some people are looping through all items and finding the item exists or not. Some people are doing some complex logic etc. But, below is what I believe the good and simple way of finding a value is in drop down list of items.
    if (ddlUserType.Items.FindByValue("someValue") != null)  
       ddlUserType.SelectedValue = "someValue";  
    Do you think, is there any efficient way of doing this?

    bind Enum to drop down list in ASP.NET

    This the question asked by so many people around me and I also faced issues couple of times of my early stages of learning.This is simple but, how to get value and names as a collection and bind to drop down list is a bit difficult. Below is the simple logic to read all enums and create a list item and bind to drop down list. [There are many ways to get this done, but I believe below is the best way.]
    foreach (UserType ut in Enum.GetValues(typeof(UserType)))
    ListItem item = new ListItem(Enum.GetName(typeof(UserType), ut), ((int)ut).ToString("D"));
    I think, you like this post. Let me know if you have any issues.

    Friday, August 20, 2010

    Know the site template used for the SharePoint site

    Hello all, Hope all are doing fine. I believe this is very rarely needed post that we need to know what site template [Publishing site, workspace, meeting workspace, team portal etc..] was used for a particular SharePoint site. From the UI [means by navigating to SharePoint site through browser] we can't identify this. So, we need to follow either of the steps given below to identify the template used for a specific site.
    1. First option is, this is my recommended choice and very easy too. By using SharePoint Manager tool [available for both 2010 and 2007.] Download it for free from Codeplex and install it. Now, open the SharePoint Manager and connect to the SharePoint site collection. When you click on a specific SharePoint site, on the right side it will show you all the properties available in the SP object model for that site. In it find for TemplateID and check the value showing there. That's it. What is TemplateID and how to know template name from it? Navigate to end of this post for TemplateID to Name mapping.

    Monday, August 16, 2010

    Check string contains numbers in T-SQL

    I know this is looking very simple when we read. But, I had a requirement where I need to filter strings from string data type column in T-SQL. Means, some strings in database having numbers in them, and I need to get them out and do some processing. When I started implementing this, I had so many ideas and thought like, looping through all characters in each string and check whether it has numbers in it or not. But, this is not efficient and may be a stupid implementation. And after thought about it sometime, started reading T-SQL documentation and found a wonderful function which is already built in in T-sql. I am saved. Very happy to see that function and that is working very great.

    Tuesday, August 10, 2010

    Visual Studio intellisense for HTML 5

    It's the time to use the new technologies like HTML 5. Everyone of us knew about what this is and how easy now to generate some nice and rich UI without put much efforts. No complex javascript, no silverlight or flash is required most of the time and many more advantages. There are plenty of changes in CSS too. So, I believe we should start using HTML 5 in our applications. Because almost all browsers are supporting it.
    After I have written some posts on Visual Studio intellisense on Jquery and SharePoint 2010 ECMAscript Client OM, I want to write similar on the intellisense for HTML 5.

    This is very simple process than any other we have followed.