Monday, August 31, 2009

Drop down list styles in different operating systems

A question that is frequently asked in forums like the css-discuss mailing list is how to style form controls in a consistent way across platforms. Most of the time, the question is asked by someone who has just tried to do that, and noticed the difference in rendering across browsers and operating systems.

The short answer is probably disappointing to many: you can’t. Some also argue that you shouldn’t, since doing so may reduce usability. My opinion on that is that light, sensible styling of some form controls can be OK, as long as you don’t overdo it. But what if we don’t think about usability, and just want to see what actually can be styled? I’ve made a few examples that make up a longer answer to the question about styling form controls.

Find more dtails visit these urls

http://www.456bereastreet.com/archive/200409/styling_form_controls/

http://www.456bereastreet.com/lab/form_controls/select/

SharePoint 2007: Excel Services - A Quick Introduction

First of all i found a great video tutorial from the microsoft site.Please have a look it'll show you how to enable the excel services in sharepoint.



Excel Services is a new cool thing that came out of MSFT as something that comes bundled with MOSS 2007. Excel is arguably one of the top used tools for the information worker (whoaa! Information worker, now I'm talking like MSFT marketing). I utilize Excel very very frequently. If it wasn't for excel, I'd be dead. Let me put it this way, given a choice between excel and gmail, it's like choosing between pizza and hamburgers - please god, may I never see a day when I have to choose between either. Funnily enough, it's not just me, a lot of others use Excel too. And suddenly, these excel sheets that contain valuable information collect on user's desktops and start acting as mini-databases with very valuable calcuations in them. Microsoft realized this as a potential for improvement, so they bundled up Excel Services in SharePoint 2007. This basically gives you a server side version of Excel, and a tad bit more, but a tad bit less also. First of all, Excel Services is NOT like Google Spread. Not at all. In fact, you don't have a web based UI to start editing your excel sheets, and all user's concurrency issues are taken care of - none of that happens. You get some interactivity, in the shape of some standard excel features transporting over such as grouping, pivot tables, filtering etc. and the ability to parameterize your excel sheets. You can even write .NET UDFs to extend the functionality of an Excel sheet. In short, it is a great BI & data presentation tool, but it is not a great data entry tool for the web. Excel Services can be broadly split into two halves - a) What you see and use through a browser, this looks and feels a bit like using Excel, but through a browser. b) The web service API for Excel services. The advantages of Excel Services versus Desktop Excel are obvious Sheets are automatically versioned, a "god" copy is maintained - no more versions in emails and hard drives. Backups of all this important data are easy to do. You gain the capability of securing workbooks, so certain users with limited rights can see the data, but not edit the data. Also, you can establish rules such as "Show only this worksheet to anonymous users" etc. It is possible to create snapshots of the workbook and take them with you for that trip you had been waiting for. You get a major portion of the capability of Excel 2007 interactivity on a web based application. Thus, if you had colors, pie charts, filtering, you name it - a huge portion of that richness can work on a web front end. You can extend the excel sheet through .NET. Whoaaa!! You could do that through VSTO anyway right? Well, you could, but deploying those binaries and deploying updated versions to everyone's desktop is a royal bitch in any reasonable sized organization. The formulae in an excel sheet can now be subjected to the power of a huge and powerful server, running compute cluster, and thus this calculation load can be shared/distributed. And don't forget, these excel sheets are stored in a document library, so you can have workflows, rss feeds, alerts and everything else that comes out of a sharepoint document library. The disadvantages are: Not everything that works on a desktop excel sheet, may work on the web version. For instance, stuff with ActiveX controls, or stuff with add-ins will not work properly in excel services. Excel services are bundled with MOSS, so you gotta buy the nice shiny version of SharePoint to use this stuff. Stuff that you are used to in the desktop version, from a UI perspective, such as split/frozen panes, zooming, etc. won't work in excel services. Some features work in a "lite/diet" fashion. For instance, PivotChart/PivotTable reports functionality is limited to non-interactive, and limited interactivity respectively. You cannot seriously modify the workbook once it is on excel services. For instance, if you want to add a chart, you can't. You need to do that in desktop excel and republish. So, in this blogpost, I am going to create a simple excel sheet - put it on excel services, and demo how this stuff works. Here is the problem statement I am trying to solve - I am going to assume that I went to the MVP summit (though this year I didn't (too much work to do)), and over there as we go out and eat and drink, other MVPs are borrowing money from me, or I am borrowing money from them. I wish to track all this information in an excel sheet, since I tend to get drunk easily, and the tightwad that I am - I don't wanna loose track of this info. Now I'd like to use all the nice features of excel to get an idea of how much I owe, how much everyone owe's me, and use color coding/charts - all that shputz! But I want this information online, say using Excel services. Okay so Step #1 is, create an excel sheet. My Excel sheet with some sample data looks like this - As you can see, I have a simple workbook with 1 worksheet. I have a table with 3 columns, Person/Date/Amount. I am tracking who owes who what, and on what date was the $ loaned. Also, I have done a sum, and a funky 3D chart, and I am using conditional formatting and nice looking icons that appear automatically to make my data visually more meaningful and appealing. Step #2, is to go under SharedServices for the site you wish to put this excel sheet on, and under Excel Services settings, click on "Trusted File Locations". Go ahead and add the location you will put this excel sheet on. I put it on http://moss2007:10000 and I trusted all children. Step #3, is to go to the site, http://moss2007:10000 in my case, and create a document library. Go to the document library settings, advanced settings, and under "Open browser-enabled documents", choose "Display as web page". Step #4, Is to make the above excel sheet available via Excel services. If you are using a version of office that can publish to excel services, such as Office Ultimate 2007, go ahead and use OFFICEBUTTON->Publish->Excel Services, and publish to the document library created in step #3. Otherwise, just save it in that doc. lib :-). Publishing via Excel services unlocks the possibility of making available named cells as parameters to the excel sheet on the web. Named cells can be exposed as parameters by clicking on the "Excel Services Options" box in Office Excel Ultimate, during the publish process. Cells can be named using the DefineName thing on the Formula ribbon/bar. Also, if you wish to limit the publishing to specific sheets, or part of a sheet - you need to use a version of Office that has the ability to publish to Excel services. Step #5, is to go ahead and click on the excel sheet in SharePoint. What do you see? After a circular green progress circle thingie, the excel sheet is rendered as shown below - Note that I am running this in a browser :-). Even neater, check this out, the same worksheet in a WebPart - w00t!! Now, what do you see? A large portion of the functionality carried over, though Excel Services decided to turn my 3D chart into 2D (chee thanks! Lesson learnt, don't promise anything based on excel services to client, unless you've tried it yourself first). Plus, if you start playing with the above, you can clearly tell that this isn't exactly "Excel" like "Google Spread", in fact - that would be much like comparing apples to oranges. Google spread is a web based version of excel lite/diet, wheras excel services gives you the ability to put the various excel computations that business users code in an excel sheet, on a server quality machine. Then you can use stuff like Web Services to query, and UDFs to enhance. Plus, another thing you see is, Bill Ryan seems to owe me $95. WTF! Other cool things to do with Excel Services - - Play around a bit and see what stuff carries over to the web based version. Things get interesting with PivotTable and PivotChart, I recommend trying those out. - You could query the functionality embedded in excel sheets using a web service. Imagine, going up to your business user and telling them - hey man, why don't you code your complex calculations in Excel, let me know when you're done, and I'll give a web based version of it. Quite a punch IMO. - Extend this functionality using UDFs. - Use Excel to display stuff in either SQL Server BI or a SharePoint list, and use the data connection library + excel services to render this data in the browser.

Wednesday, August 26, 2009

Adding PDF icon in sharepoint

Follow the steps as mentioned below to get the PDF icon working in a sharepoint site.
1> Stop the IIS.
2> Install the Adobe IFilter from the below links -
http://www.adobe.com/support/downloads/detail.jsp?ftpID=2611 for 32 bit
http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025 for 64 bit
3> Then copy/add the icon of the pdf to "c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES"
4> Then go to "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML" and edit the DOCICON.XML
5> Add the key that is mentioned below inside the above XML file.


6> Restart the IIS.
7> Then go to Central Administration page to add the file type. Go to the SSP,then search settings, then click on File types list.
8> Click on new file type. Type in PDF, then click OK.

Finally, you get to see the pdf icons for the PDF files that you have uploaded on the sharepoint site.

Wednesday, August 19, 2009

How to hide a sub site from table of contents web part in sharepoint

Here assume a sitauation that you dont want some of your subsite appear in your table
of contents web part.

You have go to
--> Site "Settings"
--> "Modify all site settings"
--> Click "Navigation" under "Look and Feel"
--> Go to Current Navigation
--> Select the sub site that you do not want
--> Click "Hide"
--> Click "OK"
--> Go to the page where you have the table of content web part & refresh

Now see your sub site won't there

Tuesday, August 18, 2009

How to add pagewise security in sharepoint

When you want to your page visible to a specific person or a user group you have to go to

--your page library
--Click the arrow and click on "Manage Permissions"
--add or remove permissions
--chekin the page

Then you are done :)

SPSecurity.RunWithElevatedPrivileges - while using it with SPContext.Current.Web in sharepoint

Normally we will use SPSecurity.RunWithElevatedPrivileges() to execute some code that has to be run under some higher privileges.



Whenever we use SPSecurity.RunWithElevatedPrivileges(), it will execute the code under the context of Application Pool identity. Now we can see a scenario where we will get the “Access denied” exception from the code block even if you use SPSecurity.RunWithElevatedPrivileges.



This was the code snippet that I have used initially inside a custom webpart to read XML content from of an InfoPath form which was uploaded in a document library. This code will throw an “Access denied” exception while calling the OpenBinaryStream() method whenever I execute it through an Anonymous user account.



SPSecurity.RunWithElevatedPrivileges(delegate()

{

SPWeb oWeb = SPContext.Current.Web;

SPList oList = oWeb.Lists["InfoPathLib"];

SPListItem oListItem = oList.Items[0];

Stream oStream = oListItem.File.OpenBinaryStream();

StreamReader oReader = new StreamReader(oStream);

string strLine = "";



strLine = oReader.ReadLine();



oReader.Close();

oStream.Close();



oReader.Dispose();

oStream.Dispose();



lblFileContent.Text = strLine;



this.Controls.Add(lblFileContent);

});





Here the problem was, whenever we take the SPWeb instance using

SPWeb oWeb = SPContext.Current.Web;, then SPWeb instance still running under anonymous account only , because we are taking it through the current web context in which the current user is running under anonymous account (IUSR_MachineName). That was the reason that we got that “Access Denied” exception. We need to remember this point all time whenever we use RunWithElevatedPrivileges under the web context.



So what we need to that, we have to take the current context outside the SPSecurity.RunWithElevatedPrivileges block and then create a new instance of SPSite and SPWeb inside the that block which will run under application pool identity.



SPWeb oWeb1 = SPContext.Current.Web; // taking the current SPWeb context running under the anonymous account

SPSecurity.RunWithElevatedPrivileges(delegate()

{

using (SPSite oSite = new SPSite(oWeb1.Site.Url))

{

// creating a new SPSite running under Application pool idenity

using (SPWeb oWeb = oSite.OpenWeb())

{



SPList oList = oWeb.Lists["InfoPathLib"];



SPListItem oListItem = oList.Items[0];



Stream oStream = oListItem.File.OpenBinaryStream();



StreamReader oReader = new StreamReader(oStream);



string strLine = "";



strLine = oReader.ReadLine();



oReader.Close();



oStream.Close();



oReader.Dispose();



oStream.Dispose();



lblFileContent.Text = strLine;



this.Controls.Add(lblFileContent);

}

}



});

The above code will work fine and we can read the InfoPath document. So, please do not forget to create a new instance of SPSite and SPWeb inside SPSecurity.RunWithElevatedPrivileges,while using it in a web context.



Another work-around to this paritcular requirement (read the file content) is - use GetFileAsString() method of the SPWeb directly. And here there is no need to use the SPSecurity.RunWithElevatedPrivileges. Since, I have enabled anonymous authentication on this SharePoint web application it will allow to read the file using the below method under the context of anonymous account.

string strXML = SPContext.Current.Web.GetFileAsString("/FannyDocLib/Form1.xml");

Sunday, August 16, 2009

How to print web page in sharepoint



Add the above script to the page you want to give print function.Then you are done.

Friday, August 14, 2009

System.IO.FileNotFoundException: The Web application at http://-.-.-.- could not be found. Verify that you have typed the URL correctly. solution

System.IO.FileNotFoundException: The Web application at http://203.143.39.19 could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.

You can verify this error when you type the public url as http://xxx.xxx.xxx.xxx/ you can not access your your web site.

You may access it using your intranet access or local host.

Then go to Central Administration > Operations > Alternate Access Mappings

Then Edit Default and set your public IP as default.

Then gooooooo to http://xxx.xxx.xxx.xxx/

wow! you are there

How to hide global navigation tabs in application.master in sharepoint



Find the section (in the box in the image) in application.master (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS).
Then add a div tag as shown including the above mentioned section and make it
visible false.Then you are done!

How to redirect to a custom search page from OSSearchResults.aspx search page


In SharePoint MOSS 2007, when you turn on the custom scope in site collection’s “Search Settings”, most of search results will be displayed at /SearchCenter/Pages/results.aspx. The exceptions are at the contextual search (This site, This List: Documents etc) and it always displays the search result in OSSearchResults.aspx page, which you can not customize through web parts (as you can do with /SearchCenter/Pages/restuls.aspx). This trick seems works very well (original post here):

Open OSSearchResult.aspx in layout folder, and add this block:



I added right after the stylesheet block and I guess you can remove some un-used code block since this page will not be used at all.

Hide "Sign in" Link from sharepoint pages for anonymous users



Hide the sign-in link on the Sharepoint sites except admin page
Did you want to hide the sign-in link on your SharePoint sites?
All you need to do is to locate the following code in your master page and hide or remove the tag:

Step 1:


This will hide the whole Welcome Panel when the page is displayed in the web browser. Donot remove the welcome.ascx control from the Controltemplate folder.
The welcome menu is part of the link itself. Its a whole functionality which is contained in welcome.ascx. So if you remove that, you will loose the menu too.

Step 2:

Create the ASPX for a admin user called adminlogin.aspx
Place the the following code in the ASPX page
The "Sign In" link available in the top-right corner of the Sharepoint site except
the admin page.

Configure sharepoint search for anonymous users - OSSSearchResults.aspx

If you have a public Sharepoint site (MOSS 2007 or WSS 3.0) that is accessible to anonymous users and you’re not using custom scopes, you probably already noticed that every time users try to search they get a user prompt. To get pass this prompt you must enter valid username, otherwise you’ll get famous “Access Denied” page. So much for anonymous access, right?

Anyway, the problem is with OSSSearchResults.aspx page, specifically with one of the inheritance reference that ASPX page. I’m talking about the part of the code that sets the inheritance of the page from the generic application page base class, which is not really required for this page to function properly.

To allow anonymous users to search your publicly available sites you need to remove that inheritance from the code, so find part of the code inside the Page tag that states “Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" and remove that part of the code (not the whole line, just the part that inhertis the application page base.) OSSSearchResults.aspx page is usually stored at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS on your SharePoint server. Make sure you backup the file before making any changes!

Making those changes will not only allow anonymous users to search the SharePoint content, but also will keep the SharePoint search secure, meaning that anonymous users will only be able to search the part of the SharePoint they have permissions to view.