Tag Info

Hot answers tagged

18

As James mentioned, your main mistake is that you are using Page.Header.Controls. It is much simplier: this.Controls works like a charm. If it will not work, you should then check your delegate control declaration XML code. It should look like this: <Control Id="AdditionalPageHead" Sequence="1000" ...


7

You should not edit the person.aspx in the file system (updates will likely overwrite it). SharePoint Designer is the first option, but not a good one. It will customize the page and you will not benefit from pre-compilation, and can cause headaches when upgrading! One approach that I've previously uses is to add a new feature that puts a control in the ...


6

Hm. What I would do is do the work in CreateChildControls. Have it just add the two LiteralControls to the this.Controls collection. Then, add your ASCX to the AdditionalPageHead delegate control via your Feature. (step 33 in that article you linked to). There is a reason (and at this time in the morning I can't remember what it is), but the Page.Header ...


5

I'd recommend you use the ScriptLink control instead. It allows you to inject your JavaScript code into the page header, where they script-tags belong. It also allows you to avoid multiple imports of the same file. Also, the recommended location for script files are in the /_layouts/ folder ({SharePoint Root}/TEMPLATES/LAYOUTS) This is how to use the ...


4

Check out this article from Randy Drisgill. It's exactly what you need. Add the s4-notdlg css class to each div you want to hide in dialogs. http://blog.drisgill.com/2009/11/sp2010-branding-tip-2-custom-master.html


4

You could open the site with the SystemAccount token. It is more recommended than using SPSecurity.RunWithElevatedPrivileges. I would do it like this: private void LoadSubsites() { using (SPSite site = new SPSite(SPContext.Current.Web.Url, SPUserToken.SystemAccount) { using (SPWeb web = site.OpenWeb()) { var sites = web.Webs.Select(w => ...


4

Just for starters, I think you have called the ExecuteOrDelayUntilScriptLoaded function in a wrong way.(You have given an extra set of curly braces for the function inside. Try this code: string getJS(string title, string htmlContent) { return (string.Format(@" ExecuteOrDelayUntilScriptLoaded(function () { var options = ...


4

The line <Property Name="QueryPromptString">$Resources:MyResourceFile,ResourceKey</Property> wokrs fine for me. I think that you should check your resources file. This file should contain ResourceKey which you tries to use in this property. If you use correct resource file and key, the search control displays text depends on the site language. ...


4

I exactly had the same problem. After some investigation and trying out different approches I finally found the solution: 1) Do NOT place the @Register-statement before the DOCTYPE declaration 2) Instead you can place it directly within your Custom ASP.NET Markup Snippet - just before the usage of your custom control Hope that helps!


3

Commented migrated to answer: Add the User Control via the templates, do Project -> Add -> New Item -> User Control. This creates the ASCX and the associated CS file.


3

A webpart is a just a kind of asp.net control, nothing specific to SharePoint considering what you want to achieve.You can use javascript\jquery\ajax to add controls dynamically. With javascript\jquery, you can add HTML controls.Check this : http://techbrij.com/445/add-dynamic-form-elements-textbox-button-radio-checkbox With Ajax Updatepanel, you can add ...


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

It depends on what you want to achieve. User Controls are controls which in general are ment to be statically placed on a specific pagelayout or masterpage. Like forinstance the QuickLaunch or GlobalNavigation are static controls in the masterpage, as they are ment to be shown on every single page, regardless of where you are on the site. Webparts on the ...


3

All good answers, I'll just add that both WebPart and UserControl are derivatives of System.Web.UI.Control, and as such are just two different tools in the same box. Normal practice is to build the UserControl, then add a WebPart that simply loads it. This gives you both options for use. In your case you are probably going to use UserControl since ...


3

As far as I know you have to add each control template separately. Another option would be to write code which iterates through all your custom control templates and add them programmatically, wrapping this code in one control template.


3

You can't. The syntax for @ Register with a user control is: <%@ Register tagprefix="tagprefix" tagname="tagname" src="pathname" %> Where src The location (relative or absolute) of the declarative ASP.NET User Controls file to associate with the tagprefix:tagname pair. tagname An arbitrary alias to ...


3

I think the error message states that your UserControl (CustomNavUserControl.ascx) does not implement IHierarchicalDataSource. So your code behind file (CustomNavUserControl.ascx.cs) of your UserControl must implement this interface.


3

You may perhaps try using Delegate Controls and the AdditionalPageHead delegate control can be the best candidate as it is available in all OOB master pages.


3

I got the following code from the MDSN on line libray: <%@ Page Language="C#" %> <%@ Reference Control="~/Controls/Spinner.ascx" %> <script runat="server"> private ASP.Spinner Spinner1 protected void Page_Load(object sender, EventArgs e) { Spinner1 = (ASP.Spinner)LoadControl("~/Controls/Spinner.ascx"); } protected void ...


2

Microsoft does not support FIPS with SharePoint 2010. "SharePoint Server 2010 uses several Windows encryption algorithms for computing hash values that do not comply with Federal Information Processing Standard (FIPS) 140-2, Security Requirements for Cryptographic Modules. These algorithms are not used for security purposes; they are used for internal ...


2

You could certainly create logic that modifies the visibility of a control based on context, such as the page name. But I would avoid having logic that depends on hard-coded "magic" page names - I think it will lead to confusion further down the line. When you say "template" I assume you mean page layout, and I would suggest that if you have two categories ...


2

Jan has made specific SmartTemplates to deploy user controls in WSP builder: http://www.codeplex.com/smarttemplates


2

The typical pattern used here is to use a timer job to make the changes in the web application root. As you've no doubt noticed, such changes are outside the scope of SharePoint's solution framework. Here's an example of this from Gary Lapointe.


2

ascx files are stored in the COntrolTemplates folder in the 14 hive of sharepoint. So it's path will be something like: private const string _ascxPath = @"~/_CONTROLTEMPLATES/ProjectFolder/controlname.ascx";


2

You can use the WebBrowsable properties of a property in a web part. Like the following : [WebBrowsable(true), WebDisplayName("Items count"), WebDescription("Items count"), Personalizable(PersonalizationScope.User)] public int Count { get; set; } EDIT : In the case (see the comments below) where you don't want to check-in/check-out the complete page, ...


2

First at all you should open new site context SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID)) { var sites = web.Webs.Select(w => new { Title = w.Title, Url = w.Url }); if ...


2

I solved this problem. There is my code private SiteMapNodeCollection GetNodes(SPWeb web) { HttpContext temp = HttpContext.Current; try { HttpRequest request = new HttpRequest("", web.Url, ""); request.Browser = new HttpBrowserCapabilities(); HttpContext.Current = new HttpContext(request, new HttpResponse(new ...


2

You can use jquery Ajax pretty easily and either have the response return some more html which you can add to an element on the page or build elements based on data returned. The update panel is a simple way to implement ajax in ASP.NET but may be (depends on req) more difficult to add controls dynamically (you may end up using JS anyway.


2

for starters, you are calculating start and end dates differently DateTime StartTime = Convert.ToDateTime(item["EventDate"]); DateTime EndTime = Convert.ToDateTime(item["EndDate"] ).Date; You should also use Convert.ToBoolean() rather than casting it as x = (bool) object. I've seen the latter fail in strange ways and if that happens to be the case ...


2

You can use delegate controls, check this article.



Only top voted, non community-wiki answers of a minimum length are eligible