How can I show/hide webpart zone on a page layout base on condition? - sharepoint

I am very new in SharePoint. I'm using SharePoint 2013.
As a title of question. I want t create a page layout contain 4 webparts. Now I want to show / hide each of those webpart base on a condition ?
How can I do that ?
Thank for any help.

Could you use audience targeting for this? I'm not sure if this feature was removed from web parts but I know you could do it In so 2007.
The other option is to edit your web parts code. Perform a check onload, if it's true let it run through the it's normal rendering process otherwise hide. I'm not aware of a way you can do it via the page unless you use Js which I'm not sure is possible. Would be a good idea to make this a configurable web part property in case the web part needs to be available to all at a later date.
Hope this helps
Cheers
Truez

Related

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).

Sharepoint web part for editing list items

I'm trying to create a web part that will enable users to edit items without ever leaving the AllItems.aspx page. The web part should have a similar functionality like the EditForm.aspx page.
I've created a simple web part with a ConnectionConsumer("Row") that successfully shows the selected ListItem but I'm trying to figure out how to programmatically create a form depending on the list with a save/update functionality.
I would appreciate a simple solution or a nudge in the right direction.
Thanks
What you are trying to do is not possible out of the box but it should be possible to use the SPGridView and the ListFieldIterator decorated with AJAX to get the things working as you wanted.
You can refer to the below items and build a control that does what you want.
Using SPGridView in WebParts
Articles on ListFieldIterator
ListFieldIterator
Once you build it you can try sharing the code as this is a pretty common thing everyone wants and I didn't find a good implementation of this kind so far.
This definitely sounds like a nice feature. I would love it if you could put the solution on codeplex, you're choice of course.
I've had a sneak peak on SharePoint 2010 and AJAX enabled editing is found on lots of places so I wouldn't be surprised if some kind of feature like the one you are working on will be included.
Good luck!

SharePoint ASP.NET Mock Site

Does any one know if there is a ASP.NET website available that is a pretty good clone of the style and layout of a SharePoint site? I don't need the functionality of SharePoint, I would like to be able to quickly mock up some controls for SharePoint, with out having to actually deploy stuff to the server, and want to be able to see what the controls would look like rendered in SharePoint.
Make sense?
If there is nothing available I'm just going to do a "save complete" with FireFox on my SharePoint site, and convert the results into a master page that I can use. If someone else has already done the work, that would be fantastic.
Heather Solomon has an excellent SharePoint CSS Cheat Sheet. Also, if you use sharepoint native controls like the SPGridView, most of the styling will be inherited / already implemented for you.
Your 'Save Complete' idea is the one I would suggest. You could also have some sort of bookmarklet/script that receives a html page url and injects it into the sharepoint page without actually changing it, but it is way more complicated.
My advice would be to use SharePoint Designer to play with the design and to use Features for deploying the customizations. Your question is pretty vague in that I can't tell if you have access to a VM to do a test install? Also, are we talking WSS 3.0 or MOSS 2007 or the latest version? Is it a publishing site? What kind of controls are you working on? Web Parts?

Customizing SharePoint's NewForm.aspx, or creating my own form... thoughts?

I'm not sure that there will be a definitive answer to my question, but I'd like to read some discussion from other folks on this... here's some quick background.
I'm creating a request form that will handle adding new equipment to our datacenter. I'm collecting some pretty basic info about the submitter and the equipment to add. Some of the metadata gets pretty complex, but I won't get into that here.
At first I started with a browser enabled InfoPath form, because most of our users aren't licensed for the InfoPath rich client. After much frustration I got things working, but could never get a level of performance that I was happy with. Since then I have been playing around with SharePoint's web services and I have a GREAT form that I've written in HTML (with some jQuery magic) that submits to a SharePoint list.
So now I'm asking myself... why not just use this form? First, I can get rid of InfoPath completely... that also helps us out with licensing since I won't need Enterprise licensing. Second, performance... Third, sure I have to hand code it, but I can, and I enjoy it.
So, InfoPath is out the door.
That leads to where I need some best practice ideas mixed in with new ideas. I've got this form that works great, but I want everything to work within SharePoint. As a test, I just created a new view for my list, removed the web part that shows the list, and plopped in my form. Aside from some CSS issues, everything works and it updates the list lightning quick!
But should it be a custom view? Should it live somewhere else? Should I just edit NewForm.aspx?
I'd love to hear some thoughts on this. Ultimately, my entire solution will be deployed as a Feature, but I'm not sure that's relevant.
Thanks!!
I would've done it mostly the same way:
Create a new form (via SharePoint Designer or a custom ASPX page)
Encapsulate the form in a Web Part (you can use the SmartPart Web Part if you're in a hurry)
Create as many custom views as you want, it doesn't really interfere with the way you code the form
If you must modify NewForm.aspx, don't delete the default ListForm Webpart since it's used by SharePoint for other things. You're better of just hiding it to avoid future issues.
Hope that helps
I think you should create custom form templates for your request SharePoint-List.
See MSDN: Creating Custom Form Templates.
I also recommend reading Understanding SharePoint: List Forms.
There's nothing wrong with using a custom form or a completely seperate app to edit SharePoint data. You end up with the same data you would get from using the standard new form, so it can't possibly break anything beyond the modified view.
Setting up a custom newform is probably the most appropriate place for it - easy enough to change the newform url in schema.xml or through designer.

Hyperlinks In Sharepoint Webpart

I've been working on a SharePoint project and I have gone the route of loading User Controls through a custom web part.
I have several web controls where I need to dynamically generate hyperlinks (in a loop from a database) that will call certain functions of the User Control when clicked.
When I'm building my own ASP.NET sites, I just add parameters to the hyperlink and check on the page load to see if I need to run any other code when a hyperlink is click.
I'm starting to realize that this probably won't be very reliable inside the SharePoint environment because I don't control the way web page URLs are formed.
I would prefer to have it post back when the hyperlink is clicked and pass some values, but I'm not sure the best way to approach this.
Could someone point me in the right direction?
Thanks.
You can still add querystring parameters to the end of any url and your webpart will pick them up.
The way you create the url will have to be a little more sophisticated in that you cannot assume yours will be the only query parameters on the url.
The SPHttpUtility has some helpful functions.
If you want to avoid the complexity of dealing with and parsing URL's then you need to be using the ASP.NET server controls - the whole idea of them is to abstract out complexity such as that.
http://msdn.microsoft.com/en-us/library/seey0yt3(VS.85).aspx
http://www.startvbdotnet.com/aspsite/controls/linkbutton.aspx

Resources