Hot answers tagged asp.net
10
This has really improved in SP2010. Now you can write to the ULS logs easily even with SharePoint Foundation. All you have to do is this:
SPDiagnosticsService diagSvc = SPDiagnosticsService.Local;
diagSvc.WriteTrace( 0, // custom trace id
new SPDiagnosticsCategory("My category",
TraceSeverity.Monitorable,
EventSeverity.Error), // ...
6
If you examine page source you will see that Select Display Language > Language calls simple javascript:
OnSelectionChange(1033);
Where 1033 is language id.
I have tried launching this form FireFox FireBug console and it works. So your link could be something like:
<a href="" onclick="OnSelectionChange(1033);">English</a>
You can also ...
5
Remember that SharePoint web applications can have multiple URLs since they can be extended onto different IIS websites e.g. http://authoring.site.com and http://www.site.com.
If you're looking to get the URL for the default zone (either with a web app which has been extended or not), you can use:
webApp.GetResponseUri(SPUrlZone.Default);
5
As a seasoned ASP.Net developer, I can tell you for certain that you could not have done this with a few web forms in ASP.Net. You would have had to build numerous subsystems for all of the various parts (security, document management, membership, retention, etc). You would also need the obligatory management UIs for all of those subsystems. In addition, ...
4
Just to elaborate on Wictor's answer, his example will log 'Unknown' to the Area column.
SPDiagnosticsCategory has an 'Area' property, but unfortunately its protection level is set to internal.
However, you can set it using some reflection code. Listed below is an example of how to write to the SharePoint 2010 trace log using reflection. I use it in a ...
4
+1 to James. I want to add to it, too. While SharePoint does a great job with security and collaboration, since this will be customer-facing you should take a good look at whether the collaboration features meets your requirements. For example, the discussion threads are great for an intranet environment, but they do not look and feel like discussion board ...
4
To clarify: I assume that you have a document library with pages in it, and you intend to reimplement "Delete document" ribbon button functionality:
One of the approaches could be to get selected item using SP.ListOperation.Selection.getSelectedItems(), and then use SharePoint Client Object Model to delete it. This is an intended approach.
But also it's ...
4
You can follow steps below:
1) Create a copy of SignOut.aspx in the Layouts folder. Rename it as
CustomSignOut.aspx
2) Open the custom page in notepad\designer. In the function _spBodyOnLoad() replace windows.close() with windows.location("YourHomePageRelativeUrl");
3) Make this page the default sign out page for the web application using below command ...
4
Honestly, Denial of Service are better (and must be) handled at levels below SharePoint i.e. ASP.NET, IIS, OS or infrastructure levels. Being an application stack, SharePoint would have no or limited tools to prevent such attacks. Also, trying to handle it at SharePoint level would prove inefficient.
I would recommend posting the question in ASP.NET/IIS ...
4
It's throwing the error because the <asp:ScriptManager> tag is most likely defined in your master page, causing two instances on the page you are trying to load.
http://social.msdn.microsoft.com/Forums/br/sharepoint2010general/thread/54c271ee-de71-4e47-b02b-29a1d540b81c
4
"It depends" :)
No code is great when you want to do something reasonably small, quick, not wide ranging on your site. You can do a fair bit with JavaScript, content editor webparts and client object model.
It isn't particularly scalable though. You end up copying a lot of stuff around, hacking away at master pages in notepad, that sort of thing just ...
3
SharePoint will simplify many user-oriented requirements you may have - such as authentication, permissions control and personalised areas (with MySites).
With regards to any other features of SharePoint which may simplify your development, it's difficult to say without any further details of general requirements.
If some of your customers do want ...
3
It won't cause a memory leak but it's not best practice.
Some API calls require SharePoint to have parent SPWeb and SPSite objects initialised. Accessing the list once its parent web object has been closed could cause errors (perhaps not in this exact code).
My opinion is to play it safe and don't risk it.
3
Counting the contents of the item collection can be very slow. Instead use the ItemCount property on the list.
With regards to checking for leaks, have a look at SPDisposeCheck.
3
I've never used SmartPart so can't comment on it exactly. However there should be no need to manually copy anything if you are using a packaging solution such as WSPBuilder which can handle all this for you.
There's some pretty good doco on the non-SmartPart route:
From SharePointDevWiki, SharePoint Development with Visual Design User Controls
An article ...
3
If you stick in a Quick Add Group with the same name as your "wide" one, it'll show up at the top of the list by default when someone tries to add a web part in that zone.
However, it will show up as normal further odwn the list when someone tries to add to another zone.
However, I don't think it's actually possible to do this at all - the only method I ...
3
I'm guessing you want the dialog to open at page load, not as a result of a client-side button press (which is a little easier). You have to make sure the Sharepoint ECMA-libraries are loaded. It's easiest to use jQuery to register the opening of the dialog as a load event; if you use regular javascript in some browsers your load event will take place before ...
3
I think that your masterpage isn't complete, missing a lot of javascript references and a lot of contentplaceholders.
at http://startermasterpages.codeplex.com/ and http://archive.msdn.microsoft.com/odcSP14StarterMaster starter masterpages can be found. THey contain the minimum set of contentplaceholders, controls and javascripts that you need when ...
3
Other than workflow or a timer job I can't think of a way you could do this. I suppose you could do it as part of some kind of batch process outside of SharePoint (i.e. not a timer job, but probably wouldn't recommend that).
For workflow, you could develop a simple workflow in SPD that launches when the item is created (...we'll assume the default value of ...
3
First a number of small remarks:
Usually you don't hardcode the URL of the site you want to work against. It may be ok but if you want to access the current site the just use SPContext.Current.Web
Unless you need to make updates on a get you shouldn't set AllowUnsafeUpdates
A listbox will not allow you to add images inside it (so in my code I just added a ...
3
A couple of issues:
The Id part of SPFieldLookupValue should be the Id of the listitem in the list with groups (Groups?) not the Id of the item you're updating. So ideally you setup the ddlGroups with Text=Text from Groups and Value=Id of corresponding listitem in Groups.
The code to populate the ddlGroups should be changed to:
foreach (SPListItem ...
3
It very much depends on what part of the User Control you need to work with?
The .ascx file is usually placed in the CONTROLTEMPLATES 12 hive folder.
Path: /12/TEMPLATES/CONTROLTEMPLATES
Usually, in SP2007/VS2008, you create an .ascx page (which is actually just an .aspx page without the auto generated .cs file). So you'll have to create a class file and ...
3
This is because the UpdatePanel updates all the content WITHIN the UpdatePanel itself, meaning it recreates the DOM within that, excluding all javascript from outside the Panel.
It has to be pointed out that moving the javascript within the UpdatePanel will not help.
You'll have to use the Sys.WebForms.PageRequestManager.getInstance(); in order to make ...
3
You have probably read .NET Framework support in SharePoint 2010 ?
Basically, it stated that SharePoint can't run on .Net V4 (I guess it's because of the workflow engine, but it's only a supposition).
If you require something that works with V4, you have to create your own application. This application can then consume data in SharePOint using remote api ...
3
The client side (no-code as you call it) approach is non-destructive to the platform as it all happens with what SharePoint natively serves up. If something breaks, you remove the problematic script and you're back functioning natively without any fancy customizations. If done right, this can still be very powerful and SharePoint gives you native version ...
3
Lists.asmx is the wrong service to use. My head banging into the subject suggested that there are 3 ways to upload to Sharepoint:
Copy.asmx web service
WebDav
Frontpage Rpc (Remote Control Procedures)
To summarise the first two are limited by Windows to file sizes around 2MB for reliable transmission (higher and you can get OutOfMemoryExceptions). This ...
3
You could use relative paths, like in most web development, like
/_layouts/images/hello.jpg
Or use SPUrl tokens inline in the src or href attribute. See more here: http://hristopavlov.wordpress.com/2008/12/08/urlaction-tokens-of-the-customaction-feature/
This link is 2007, but most tokens should still be valid!
3
The problem is likely because you are using jQuery 2.0 which does not have support for IE 6/7/8 or IE 9/10 when running in compatibility mode (which I'm guessing SP 2010 is using. You can confirm this by using the F12 developer tools).
I would recommend using jQuery 1.9.1 for use with SharePoint and so you still have support for the older browsers.
2
You need to set the Welcome Page for the site. This can be done either in your ONET.XML under <WebFeatures> <Properties>:
<Property Key="WelcomePageUrl" Value="$Resources:cmscore,List_Pages_UrlName;/etusivu.aspx"/>
or manually in Site Settings, Look and Feel:
<siteurl>/_layouts/AreaWelcomePage.aspx
Only top voted, non community-wiki answers of a minimum length are eligible

