Tuesday, June 30, 2009

Copy data from MS Office Project to MS Word

We usually work on MS Office project when we deal with project management, project estimation etc…. So I used it to create project estimation document for forwarding that to management and client. But unfortunately, Client don't have MS Office Project installed. So I need to send him in either Excel or Word format.

I planned to copy and paste the data from MS Office project to MS word, when I did that it came like unformatted text. It's not looking good at all. I can't manually format it, Because it is a very big document.

After spending some time on it, found a solution how to do that. Please follow the process below.

    • Select the information pasted into Microsoft Word from Microsoft Project.
    • On the Table menu, click Convert, and then click Text to Table.
    • Under Separate Text At, click Tabs, and then click OK.

That’s it!!! This trick did everything like well formatted and rendered in table. It saved lot of time for me.

Hope this helps you too!! You can get the more details about it here.

Saturday, June 27, 2009

How to submit all posts to Google webmasters for better indexing all the posts in my blog?

You all know that the Blogger’s atom.xml file will burn only the top 25 results in the feed. This is the file usually we will submit to the Google webmaster tool to index our blog posts. But because it only returns top 25, Google crawler indexes only these 25 and it don’t care about the posts which are older than 25. So, there you are loosing your visitors to see those posts because they won’t be show up in the search results  because of not crawled well. So how to solve this issue? and how to submit all posts to Google webmasters?


Before you proceed, please check the below posts once for the better understanding.

  • How to submit your blogger blog site feed to Google webmasters if you enable the option Post Feed redirection url. View here.
  • How to see all posts in the atom.xml feed instead of getting only top 25? View here.

Once you read above posts you will get complete idea of how to solve the problem.

  • Open Google webmaster site and submit the below url
  1. For submitting the top 50 blog feed results then use


  1. For submitting from 50 to 100 results then use


So you can submit all the posts to Google webmasters to crawl all the posts instead of only top 25. How good it is?

Bloggers feed is showing only 25 posts, how to get all?

This is the question in my mind from long time that why feed is not showing all the posts when I open atom.xml. It always get me the top 25 posts in the feed. So how to get all the posts?


  • We need to use certain querystring parameters to solve the issue to get all the posts.
  1. start-index : Which tells to the blogger feed generator that starts from this post.
  2. max-results : Which tells to the blogger feed generator that the number of maximum results count from the start index.
  3. redirect : Which is not actually needed. If you enabled post feed redirection then only we need this. But, better to keep this always in the feed url. You can find the more information about it here.

How to use:

After the atom.xml feed url, append the below querystrng url.


For testing you can browse my feed http://praveenbattula.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=50

Which will burn you the top 50 posts in the feed. Actually we get top 25 only by default, but from the solution I told you, which will return how many posts you want.

For getting top 100 results use this querystring url


For getting the results between 50 to 100, use this


You can give any value to the parameters start-index and max-results to get that many results…

Happy Blogging.

How to submit blogspot feed to Google webmaster where feedburner feed is enabled in blogspot blog

I enabled the option Post Feed redirection url in my blog settings. From the time I did that Google webmaster tool is started giving the error "URL not allowed". But I need to enable the post feed redirection to Feedburner instead of general atom.xml feed. So how to solve this problem? After read the Google blog documentation found some attributes how to solve this issue.

For my blog the atom/feed url is http://praveenbattula.blogspot.com/atom.xml. When I type this, it will redirect to my feedburner url http://feeds2.feedburner.com/praveenbattula. So when I submit the atom.xml in the Google webmaster it’s not taking this and gives me the error "URL not allowed" because of the redirection. So finally I understood that redirection is the problem.

If you want to use custom redirected feed like FeedBurner then you need to use the "redirect" querystring parameter to the url of your feed, which stops the redirection.


So, when I use the url http://praveenbattula.blogspot.com/atom.xml?redirect=false i always see the message "successfully crawled" in Google webmaster tool.

So except in Google webmaster tool I don’t use the redirect querystring. So, all users will see my customized feedburner feed, only webmaster crawler see my atom.xml feed. How nice it is….

Nice tip!!!!

Friday, June 26, 2009

Database Publishing Wizard – Generate Script for Schema and Data

When working with databases we may get a requirement to generate the script for the schema and sometimes generate the script for data too. For generating script for Schema is what we will do usually in the projects, but generating the script for data is not everyone requirement. But sometimes we need to do that as well. So this article explains both generating the script for Schema and data.

There is a cool feature from Microsoft sql server team which will do this for us, called Database Publishing Wizard. It has the commands which supports for generating scripts for schema as well as data.

You can download it here.



Command to run which will create schema and database:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql”

Command to run which will create schema:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -schemaonly

Command to run which will create data:
C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz script -d AdventureWorks “C:\AdventureWorks.sql” -dataonly

Note: Don't try it on the databases which has the size more than 100MB, it will hang your computer for a while.

Microsoft SharePoint server 2007 Service Pack 2 update

We know the expiration issue of SharePoint server after install of Service pack 2. Now Microsoft has been working to fix it from past 2 months and finally they released an update and it is ready for download. You can install it on both the Server with SP1 or the Server with SP2 installed. You can see more details here.

So, what are you waiting for? Just download it and install on the server.

Wednesday, June 24, 2009

SQL Server 2008 Developer Training Kit

The SQL Server 2008 Developer Training Kit will help you understand how to build web applications which deeply exploit the rich data types, programming models and new development paradigms in SQL Server 2008. Which has plenty of demos like

  • Spatial Types Demo
  • Intro to Filestream Demo
  • SQL CLR Nullable Types Demo
  • Programming with Filestream Demo
  • Reporting Services Web Application Integration Demo
  • Date and Time Support in SQL Server 2008 Demo

and many more…. It is really very cool one. It will give you lot of features or options to implement more to add your own stuff. You can download it here.

Windows 7 RC training kit on Visual Studio 2008


Again I came up with Windows 7 blog post. I am waiting for Windows 7 release and here is a post which is for letting you know that we can customize Windows 7 system depending on our choice. We can get the toolkit and with the help of Visual Studio 2008 we will develop the modules and deploy it to Windows 7. This is easy to customize. For this you need to install the Windows 7 RC training kit. You can download it here.

What it contains? It has the demos on how to do and examples for different modules and plenty of presentations, which explains the developers how to proceed. This is the one of the easiest way to understand things in little time. You can customize lot of areas of Windows 7 and below are the main modules.

  • Taskbar
  • Libraries
  • Multi Touch
  • Sensors and Location
  • Ribbon
  • Trigger Start Services,
  • Instrumentation and ETW
  • Application Compatibility

You need to install Windows 7 SDK before start working on it. So what are you waiting for? Common download and rock on it!!!

Thursday, June 18, 2009

Knowing browser width and height [for all browsers]

Today, at my work I need to implement java script for a SharePoint web page. First I developed the javascript in simple HTML page and after it is successful running I moved the code to SharePoint page.

In html page, it was working very fine and on the SharePoint page it was not. After some research I found the problem in the line document.documentElement.clientWidth and document.documentElement.clientHeight. I don’t know what the problem with this. I was browsing both HTML page and SharePoint page in the same browser. This behavior is weird.


I researched on the javascript functions and read all the properties available for the document object and below is the code I came up with.

function GetWindowProps() {
            var browserWidth = 0, browserHeight = 0;
            //For checking non-IE browsers Mozilla, Safari, Opera, Chrome.
            if (typeof (window.innerWidth) == 'number') {
                browserWidth = window.innerWidth;
                browserHeight = window.innerHeight;
            //All IE except version 4
            else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {               
                browserWidth = document.documentElement.clientWidth;
                browserHeight = document.documentElement.clientHeight;
            //IE 4
            else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                browserWidth = document.body.clientWidth;
                browserHeight = document.body.clientHeight;

This will give you the correct values and it will work for any browser. How is it?

Monday, June 15, 2009

Sql server management studio for sql express

This is the question from most of the people around me and the forums etc asked. When once they completed installing Visual Studio or directly SQL Express on their machines, always they are failing to open the database in sql server management studio because when they go to all programs, sql server they didn’t find sql server management studio there. So, how to see all the databases or to create one?

By default sql server management studio won't come with the sql server management studio installation. So, we need to install sql server management studio express manually for viewing the database or creating one. You can download the management studio express here.

Isn't a nice tip. Feel free to post a comment.

Will post more like this. Keep an eye on my blog!!!

Wednesday, June 10, 2009

How to see actual exceptions or errors in SharePoint instead of Unknown errors message

When I was new to SharePoint programming, I faced plenty of problems to find out what errors or exceptions coming on a SharePoint web page. Because as of my knowledge those days, I thought like there is only one place where we can find the details of the exception or error coming and that is nothing but logs. [Which usually located in 12 hive.] But after got some experience with SharePoint slowly learning new things and found a way to see the exception directly on the screen[browser] instead of going to logs and check there.

When an exception comes in SharePoint environment usually the page we see is Unknown error, nothing else. 

To see the actual exception details follow the steps below.

  • Go to the location where your SharePoint application is present in the file system. It is usually at the location inetpub/wss/virtual directories/[port number].
  • Find the web.config file.
  • Take a backup of it.
  • Open the file in some nice editor like Visual studio and find the tag <SafeMode
  • This is the first child tag under <SharePoint>
  • You can see the tag syntax something similar to this.

     <SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" …….

  • One of the attributes for <SafeMode called CallStack, which holds the boolean value which tells to SharePoint framework whether to show the actual exception details or not.
  • Set this value to true in-order to view the actual exception details on screen[browser].
  • Set the CustomErrors section to Off to view complete details as shown below.
  • <customErrors mode="Off" />
  • IISRESET is not compulsory. If you do then that will be good.

Hope this will help to you to make fast development and no such big pains to look into all the log files for errors.

Note: Please use this option only on the development environment to make development fast. On production servers and QA environment, don't make the above changes to the file. If you do this, all your end users will see the actual exception or error details, which is not good.

Tuesday, June 9, 2009

ASP.NET FileUpload and File.Open() method problems

In this post I tried to explain the problems using File.Open() method when we use FileUpload control on ASPX form.

Today at my work, I faced plenty of problems with ASP FileUpload control in SharePoint. I was creating a custom form according to a client requirement. And whenever I tried to upload a file to the document library it was failing always.
The exception I am getting was: Could not find a part of the path "file upload path."

I was frustrated trying different things for 20-30 minutes and finally thought of checking the code again for a clue. Below are the details from my analysis.
I used the following code to get the uploaded file as a stream and save it to a SharePoint document library.

using (FileStream fs = File.Open(fileName, FileMode.Open))
    //Sharepoint programming - Adding document to a document library.
SPFile destfile = folder.Files.Add(fileName.Substring(fileName.LastIndexOf("\\") + 1), fs, true);
    //your logic here

fileName is a variable passed to File.Open() method that holds the file system path of the file from the file upload control.
The above code was trying to find the file in the given path on the server. If you correctly read the above sentence, it was looking for the file on the server with the given path.

Take this scenario. I was working on machine1 which is a development environment (my MOSS server) and in which my application is also running. I was testing the application from the other machine named machine2 (client). When I try to upload a document from machine2 from the path say c:\documents\abc.docx, The server code [C#] File.Open() was looking for that same path c:\documents\abc.docx on the server, i.e. on machine1. See, there was the problem. The code was trying to find the file at the path c:\documents\abc.docx on the machine1, which doesn’t exist. This is the problem with the File.Open() method in file upload control. So never use this in the code implementation in c# when you are dealing with the FileUpload.

Here is a Solution:
using(Stream fs = fileUpload.PostedFile.InputStream)
    //Sharepoint programming - Adding document to a document library.
SPFile destfile = folder.Files.Add(fileName.Substring(fileName.LastIndexOf("\\") + 1), fs, true);
    //your logic here

If you observe, I am, here taking the stream from the fileupload control by using fileUpload.PostedFile.InputStream instead of passing the file name to File.Open().

Be careful while using the streams and know the difference between the File.Open() FileStream and the FileUpload Stream.
Hope this helps you to understand the both objects how to use and where to use.

Monday, June 8, 2009

Checkbox and Checkbox list "value" attribute

In some projects, I need to create ASP.NET controls and HTML controls on a web page and need to get the values of the controls with Request.Form[] method. Because this is the only way we can take the values of HTML controls when they are not declared with runat=server. [You take a look at my other post which explains how to take values of HTML controls in c#.] When I declare ASP.NET checkbox on a page, the value Request.Form["checkboxname"] always returns on or off. So, I never get the value of it. Because the ASP.NET checkbox don't have attribute for Value. So this is the same problem with <asp:CheckboxList> control. When I bind the data source for it, on the page it renders as two controls for each check box. One is Input with type checkbox and another is Label which holds the value as display text. So when I try to get the value I never get the check box value at all. i.e. if I declare checkboxlist for showing check boxes as ASP.NET, SharePoint, Java and want to know the value of user selection  by using Request.Form[], I always get the value on or off but not actual strings. So, how to get the value from the checkbox?

In these type of scenarios, I never use <asp:checkboxlist> on my web page. I always use multiple check boxes as a list to render on the page. This is because of getting the value in the Request.Form[""].

We need to declare a checkbox on the page and then use the below  line in c# code as shown below to set the value attribute manually.

cb.InputAttributes.Add("value", "checkboxvalue");

[If you need to build the checkboxes dynamically, then in for loop you can write the string which has the HTML check box declaration with input type="checkbox” and can access them in C# code.] So that it will render the value attribute for it. InputAttribute is the function we need to use to render it. So the final out put which render on the browser side looks like this.

<input type="checkbox" id="cb" name="cb" value="checkboxvalue" />

So, now when you try to get the checkbox value using

Request.Form["cb"] you will get the original value instead of the on or off.

And see my other post related to it, which explains you on "how to access the checkbox list values on client side".

Hope this will help to the guys, who are having the same requirements. Please give me your valuable feedback/comments. Do you think, is there any approach which solves the problem in easy way?

Saturday, June 6, 2009

Microsoft Visual Studio 2010 – The great IDE in the IT world

Visual Studio 2010. wow!!! Lot of features. What a product from Microsoft. It has almost everything integrated for developing all technologies related to ASP.NET like Silverlight, ASP.NET, SharePoint, WPF and QA related. The version of ASP.NET supporting is framework 4.0. This is again a big change.
We will take a look at the features available in the Visual Studio 2010.
First I am a SharePoint guy, so I will start from SharePoint tools available in Visual Studio 2010.
  • Till now, we have an option to add a new item for ASPX, ASCX, CSS, JS, Cs etc… Now we have an option to add a new web part project item and the Visual web part designer which loads a user control as a web part for SharePoint. Wow, how cool it is! Pretty much good.
  • We have another fantastic facility for adding an event receiver for SharePoint List/Library/Site and using the wizard to choose the event receiver type. From this, it will create a source file with that event receiver. [Again no need of creating a special project and write everything manually.]
  • A special explorer window which will pull information from the SharePoint sites like Lists, Libraries and other artifacts in SharePoint directly inside of Visual Studio when connected to a SharePoint site. It just like what we are seeing the team explorer in Visual Studio 2005/2008 when connected to Team Foundation server.
  • We have a package explorer to configure WSP files, feature files and other package related files in SharePoint. This is good thinking by the team to keep track of all the solution we are using in a SharePoint site at one place. The key F5 will compile, build, debug and deploy the solution to the specific site or farm depending on the configuration.
  • Till now if you want to create a SharePoint custom workflow we used to create a C# SharePoint workflow project and configure manually to implement it. But now, in this version they have added an ASPX workflow initiation form to a workflow project.
  • We already know about the WSP builder. From which we can create the solution file easily without doing any extra configurations etc, etc. Visual Studio 2010 includes the WSP file import to create a new solution automatically.
Second, I like Silverlight technology and development. I will explain the Silverlight features available in Visual Studio 2010.
  • While creating a Silverlight project you have an option to select the Silverlight version like 2.0 or 3.0
  • A good and great news for Silverlight developers that Visual Studio 2010 supports for both Silverlight development and editable design surface. WOW!!! this is the best and great feature. Isn’t it? [Thanks to Microsoft. When i am developing Silverlight application I am always having a thought that why MS VS team didn't give option to edit the Silverlight objects in editor inside Visual Studio. If I need to edit any thing I always need to go to Microsoft Expression Blend. But now editor is available inside it.]
  • More features available with Silverlight 3.0 in Visual Studio 2010. We will discuss this in upcoming blog posts.
Another feature that Visual Studio 2010 is integrated a great module for testing [QA].  You can take a look at it here.

The final feature is very cool feature that the new look for Visual Studio 2010. Very good rich and cool UI and very good user experience. I will come with another post that will give you good information about it with nice screen shots.

I think this information will help you to understand the features about Visual Studio in different scenarios. Keep an eye on the blog for more updates.

Friday, June 5, 2009

Exception: Only String, int, and DateTime data types can be used as the value in Properties while adding list item in document library.

This is the exception I got when I try to add a list item through c# in a SharePoint document library.


In my previous post, I explained the logic for adding list item to a document library through c# code. This works well if the list/library columns are of type int, string and date time. If I add a column of type Currency then the code will break and it won't add the list item to the library at all. Because the function list.RootFolder.Files.Add() will not accept the properties other than the 3 types mentioned, through HashTable. This is the problem with the function. To avoid that below is the code i used and this problem went away.


SPFile destfile = list.RootFolder.Files.Add(
fileName.Substring(fileName.LastIndexOf("\\") + 1), fs, true);
if (destfile.Item == null)
lblMsg.Text = "Error in adding file";
SPListItem listItem = destfile.Item;

//Logic to set list item columns like
//listItem["Title"] = "Document Title";
//listItem["CurrencyField"] = 234.908;
//listItem["NumberField"] = 12345.678;

listItem["ContentType"] = "Document"; //Default Content type for Document libraries

If you observe the code difference between my previous post and this post is, I am not passing the HashTable object to list.RootFolder.Files.Add() method. Because there the problem was. [Exception was coming from it.]

After I am adding the document then trying to set the column names of the list item by reading the same list item object which is from the line

SPListItem listItem = destfile.Item;

The below line to this line of code is for setting the content type of the document library. Take care of this one that, a document library can inherit from more than one content types. So you should mention the content type for better results.

Finally, updating the list item and updating the file to reflect the changes to the document library list items. Please feel free to post your ideas, comments and question here.

Windows server 2008 and SharePoint server

This is the best article that covers complete information about the requirements for installing SharePoint server on Windows Server 2008. This is important article because this is the starting point for the people who like SharePoint 2010. Because SharePoint 2010 install only on Windows Server 2008.


SharePoint 2010 System preliminary requirements.

SharePoint 2010 is the new version of SharePoint server from Microsoft. Which is both good and some what disappointed news for people. Don't get surprised. Good news is, it is very efficient and most performance server than it's previous version. SharePoint 2010 will work almost same as IE version on other browsers Mozilla Firefox and Safari. SharePoint 2010 is including plenty of features available and I will publish them soon. Bad news is it only works for 64-bit. So you need to change your hardware and software!!!!

  • SharePoint Server 2010 will be 64-bit only.
  • SharePoint Server 2010 will require 64-bit Windows Server 2008 or 64-bit Windows Server 2008 R2.
  • SharePoint Server 2010 will require 64-bit SQL Server 2008 or 64-bit SQL Server 2005.

Because of adding some functionalities to work for Mozilla and Safari there are very less chances that it will work on IE 6. Now a days I think there are very minor percentage of people who are still using IE 6 on their machines. If they want to view SharePoint 2010 then they need to upgrade to latest versions.

You can find more details about it here.

Creating RESTful Mashups using SPD 2007

Fantastic article on creating Mashups in SharePoint. Complete description step to step with images. Thanks for the great stuff. You can see the article here.


Adding Bing search box to your site

Bing is returning good results and everyone having positive eye on it, so planning to add to their sites almost everyone. This is why i am planning to post on how to add Bing search service on your site for faster results.

  • Go to the url : http://www.bing.com/siteowner/
  • There you can see the heading “Bing box”. Yes from here select the option basic/advanced search box by clicking Get started as shown.
  • Bing_box
  • I think everyone will use Advanced search box, so i am explaining that process.
  • You can see there 3 steps we need to follow to get the code to add search box.
  • Step 1: Pick a search type – Add the information it is prompting and click Next.
  • Step 2: Customize it – select the language and color etc… to match your template and go to final step.
  • Step 3: Copy the HTML snippet – Now you got the code and place it on your site where ever you want and get the exact matched results to the query.


How to submit your site to Bing

Bing – Wow it’s the hot keyword now in all search engines and everyone is talking about it. This is wonderful and returning results in very well manner and crawling is very fast when compared to Google. After we submit the posts/articles results are coming within an hour. Do you believe this?

So, in this article i am planning to post about submitting your site and sitemap to bing so that you will get good traffic when keywords matches the user query.

Step 1: How to add your site to Bing.

Go to the url: http://www.bing.com/docs/submit.aspx

and add the details it prompts. See the below image for more details.

Submit_Your Site_To_Bing Step 2: Add your site site map to Bing.

This is again the same process as you know. Below are the steps you need to follow to add site map.

  • Go to the url http://www.bing.com/webmaster/
  • You can see the below screen.
  • Signin_To_Use_Bing_Tools
  • Sign in by clicking the button. You can go to the page where you have options to enter your site details and site map path.
  • Site_Details

Complete the details and wait for some time that Bing crawls your content and enjoy the results.

Bing!!! Bang!!! Bing!!!

Wednesday, June 3, 2009

Windows 7 release date announced

Wow, great to know that Windows 7 is releasing soon. Its a very light weight and nice OS from Microsoft which has really very good user experience and lot of features available when compared to Widows Vista. Microsoft OEM vice president Steve Guggenheimer announced the release date and it will be release on October 22.

I am really awaiting for it.

Check out causing the item update event receivers call twice in SharePoint

Event receivers will help us to write events to add custom logic to perform operations while adding/updating/deleting items in a list/libraries in SharePoint. We can register the receivers to all lists/libraries or to a particular list or a library. Here in this post I am explaining the special case of the item update event receivers.

This is regarding the calling of these events 2 times by SharePoint framework when check out action done on a document library item. When you enable the option Require Check Out in a document library and when you choose option to checkout a document in a document library then it will call the item update events twice [If you write any update event receivers on the list then only]. So take care to avoid the unwanted call, otherwise it will do some unwanted actions. Because of it there may be chances of performance issue. Below are the details of solving the issue.

If the vti_sourcecontrolcheckedoutby property exits in the "BeforeProperties" property but not in the "AfterProperties" property, the event was caused by checking in a document. So by using this logic we will put the logic in specific block.

if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null
&& properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
    //This is when the update event is triggered by check-in.
    //This is triggered by events other than check-in action.

For more details:


Bing search provider to Internet Explorer, Mozilla and installer for Windows 7

Bing comes as a search provider like other search engine providers and getting good response. Remember Bing is in Beta and will be live in few days. This add-in is available for both Internet explorer and Mozilla Firefox, you can get it from IE add-ons site and Mozilla Add-ons site respectively.


Bing for Windows 7?

Yes, Bing is available for Windows 7 as well. Get the installer from here named bing.osdx and install it.