How to determine if Toolpart is running inside SharePoint Designer - sharepoint

A web part can't use certain objects such as Page.Request as detailed in Best Practice to create designer friendly server controls when running in a designer such as SharePoint Designer.
You can use the DesignMode property to determine if a web part is running inside a designer and act appropriately.
However this doesn't seem to work for Toolparts - it always returns false.
How do you determine if a Toolpart is running inside SharePoint Designer?

We need the Toolpane.InCustomToolpane property
So from the toolpane code its
this.ParentToolPane.InCustomToolPane
An aside - I think the reason for this difference (though its a poor reason) is that the web part page is loaded into a designer taken from Visual Studio (Whidbey) as mentioned in the msdb blog, but the toolpart is loaded into a browser window.

Related

How can I get my custom field type (lookup) to render in list view on SharePoint 2013?

I have a custom field type that was built for SharePoint 2010 that I have installed on SharePoint 2013 Foundation. The wsp installed perfectly and I get all the same functionality.
The one problem I am having is how the information is displayed in the list view. I am inheriting an SPFieldLookup and am not doing anything to override how this is displayed in the list view.
On SharePoint 2010 it renders perfectly as a hyperlink to the item which opens the standard pop out window on click etc. On SharePoint 2013 Foundation however the html doesn't render properly at all- it is almost as though it is displaying as plain text.
SharePoint 2010:
SharePoint 2013 Foundation:
My question is how can I get the lookup value to render properly on SharePoint 2013?
The same version of the wsp in installed on both machines.
Unsure as to whether this was simply a browser or client side issue I added a standard lookup field to the list and it renders fine!
I had the same issue with my codeplex project which is based on Lookup field. I added a link to dummy JS file and overrode the JSLink property of the field class. I have blogged about it here: http://sharepointnadeem.blogspot.in/2013/12/sharepoint-2013-upgrade-sharepoint-2010.html
In SP 2013 by default field rendering is done on client side. Concept of JSLink has been introduced if you want to change the look and feel of field.
However by ClientRender=False in new form url you can force it to server render mode.
So after an afternoon of head scratching it turns out that this is not a deployment issue. It probably didn't even warrant a question but for anyone who has the same problem as me...
If you edit the page and modify the listview settings you will see that there is a new setting called "Server Render".
I guess this ultimately gives you more control but in may case it prevented my fields from rendering as expected- turning this on meant my custom fields we once again displayed 'normally'.

SharePoint 2010 Visual Web Part Vs. User Control on the Masterpage

I'm new to SharePoint 2010 development and I was wondering if it was possible to add the new "Visual Web Part" to a masterpage. In 2007, I would create a user control and put the ascx reference in the masterpage. Should I continue to do the same thing for 2010 or I can I use the Visual Web Part prototype to do the same thing?
A Web Part is just a control that can be placed on a page (via a Web Part Zone) by an end user rather than a developer. But it's still a control. So, as a developer, if you want to place it on a page (or master page) at design time, you can do that.
However, if this web part is only going to be used on the master page, then you might want to continue using a custom user control like you did in SharePoint 2007. There is no need to have the extra overhead of making it available to end users if it is only meant to be used once on the master page.

What exactly can "Full Control" with SharePoint Designer accomplish?

I've been brought in as an intern to develop a SharePoint site. My team won't authorize the budget for Visual Studio and I don't have physical or remote access to the SharePoint server (running Windows SharePoint Services 3.0 a.k.a. WSS) on the back-end.
So what exactly can I do? I'm familiar with web technologies like PHP, JavaScript, HTML, and CSS. However, since the environment is SharePoint, I'm stumped trying to figure out how much control I have with Microsoft's definition of "Full Control".
If I can write some C#, I'm pretty sure that would be sufficient, but as I said no Visual Studio for me.
Any good ideas of features that people will use on a site built with the limited functionality of WSS and SharePoint Designer with "Full Control"? Can I somehow manipulate the default Web Parts into something cool or useful? Are there Ajax tricks I can do to accomplish something on the back-end?
Thanks in advance, I'm new to StackOverflow and eager to get involved here!
You can actually accomplish a LOT in SharePoint outside of a custom .NET solution. Some recommended learnings are:
JavaScript/jQuery - Know how to interface with a WebService using jQuery. SharePoint exposes a number of very useful WebServices in the /_vti_bin directory. Click here for a list: http://msdn.microsoft.com/en-us/library/ms479390.aspx. For example, I recently built a scrolling slide-show webpart entirely using jQuery and SharePoint's built-in webservices that pulls from a provided picture library.
DataForm Web Parts. Do some searching around on what these are and how they work in SharePoint. The tl;dr of these is that they're databound webparts that are bound to an SPDataSource and then rendered using XSLT to format the bound data. You can work with these in SharePoint designer, completely through the markup of your aspx page.
Do some searching on "customizing sharepoint list forms." The NewForm, DispForm and EditForm of any list or library can be customized to have behaviour or content added to them.
Those are just off the very top of my head...
EDIT:
I forgot to also mention http://www.muhimbi.com/Products/SharePoint-Infuser-%28Free%29.aspx
I've been meaning to check this out, since the concept is sound. I haven't tried it out myself but it will save you a lot of hassle when it comes to adding custom script that encompasses your entire site.

Load a web part before other

I am stuck with a problem. I am having tool part where I get all the Lists present in the Site.
I have other web part which should get the selected List in the tool part.
I see that the web part is loaded first then the tool part. so the web part is unable to the List selected in the tool part.
Please note that the text box is in a User Control.
Please help me.
I have looked at your code and found the following:
First things first. You need to move AWAY from using ToolParts and the SharePoint native webpart. they are deprecated and are a remnant from SPS2003. In MOSS / WSS 3.0 you can and should use the ASP.NET WebPart.
Secondly, I think you are mixing things up. The ToolPartGetLists is not a toolpart, it is a webpart, that in itself loads the CustomToolPart, which in turn allows you to select a list.
This toolpart is only shown when you edit the shared webpart in the UI. The list you select is then persisted to the SelectedList property of the webpart using the toolpart.
The connected webpart then tries to read the SelectedList property I guess.
Like I said, I could go and try to fix the code for you, but it is not the way to go, you really (REALLY) need to switch to ASP.NET WebPart based webparts. The native sharepoint one WILL be fased out in the (near) future.
Here you can find an example, with code! (scroll to bottom for download link). As a bonus, it uses the built in sharepoint listpicker
I don't know of any way you could control the load order of elements (web parts) on the same page.
Sounds more like you want to have your second web part (the display of the lists) have a "default" when the page loads--which could be empty. Then it would be changed to the selected list only when the user clicked a new selection in the other web part (the list of lists).

MOSS 2007: Displaying data from SQL Server Database

I have a requirement to select some data from a table in a database (SQL Server) and display it on a page in a SharePoint site (MOSS 2007).
I have a little bit of experience of MOSS, so I know I have a couple of options:
BDC
SSRS
or possibily even a custom ASPX page.
I've never really worked with any of these. Can anyone advise on the +/-'s of each?
It all depends on what functionality is required once the table is displayed in SharePoint. Do you need extra bells and whistles or is a dump of the data adequate? (Think about the future as well.) Here's some thoughts...
Business Data Catalog (BDC)
If you want to nicely integrate the SharePoint look and feel with your data as well as get some cool functionality, BDC is a good solution. There is no need to program anything and these are the features you get. However if this data will only be used once in one way then it is probably overkill.
You would need to roll your own XML description of the data so SharePoint knows how to pull it from the database (or use something third party like Lightning Tools). As Colin mentioned it requires the Enterprise license of MOSS.
SQL Server Reporting Services (SSRS)
If Reporting Services is already available for use then this is the quickest and simplest solution. It works well but can get painful as more advanced features are required in your reports.
You should be able to use the Report Designer wizard to point to your table and set everything up for you. There are SSRS web parts that can be used within SharePoint, or indeed you can run SSRS inside SharePoint using SharePoint integration mode.
Application Page
This method Steven mentioned lets you integrate an ASP.NET application into SharePoint (such that it can be accessible by a URL within your SharePoint site). This allows anything that ASP.NET does, and the code-behind will be aware of SharePoint so you can tap into that if needed as well. The cons here are code access security and deployment.
See this webcast for how to do it.
Web Part
Similar to developing an application page but much more integrated with SharePoint. A custom web part is very powerful and allows you to integrate ASP.NET code on a SharePoint page. As you would know web parts can be dragged to whatever location and give a consistent properties pane. Again, code access security and deployment needs to be considered.
If you like designer view in Visual Studio then be aware this isn't the approach that Microsoft push. You can however use something like SmartPart where you would develop your custom app as a user control and the SmartPart wraps it into a web part. I'm used to doing it the MS way now and actually prefer the additional control this gives, however it can take more time.
Page Viewer Web Part
If you don't want to touch your SharePoint installation at all then have a look at this web part. It takes a URL as parameter and displays an IFrame containing the page that would be your report, either in SSRS or standard ASP.NET.
The downside from this lack of integration is problems with sizing the IFrame, and possible security warnings from the browser if accessing the URL in a different domain.
Don't forget the DataView Webpart. It has a pretty small developement footprint and works really well as a first "cut" if you are unsure as to how hardcore you need the final result to be.
It renders using XSLT, giving you full control of the final HTML, so it can do some pretty things with Javascript and co.
For a very simple example of charting.
Have you ever used the .NET Framework do develop webpages?
MOSS 2007 uses this framework for master / template files.
So your best choice would be to create an ASPX template file to display the results on the webpage.
BDC is the way to go if you want to keep it "strictly Sharepoint". The problem is, it is only included in the Enterprise edition of SharePoint. If you have the Standard edition, you could go for SSRS and the SSRS webpart, or, create your own webpart. That way you can use your data display anywhere in your site and it's also ASP.NET compatible.
As Nat said - if all that is needed is to display some data from a database on a page - the DVWP is a great solution. Just open your page in SharePoint Designer, add the database connection, and drop the web part on your page. You can use any of the several pre-formatted layouts, or design/tweak your own so the data is displayed as you need.
Relatively straightforward, lots of HowTos online, and far faster/easier to setup than something like BDC.

Resources