Hot answers tagged

22

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


7

First create your User Control and publish is to SharePoint. Then you register a tag for your control <%@ Register Tagprefix="MyControls" Namespace="KM.MyControls.MyControl" Assembly="KM.MyControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=<Your token>" %> Then you can reference your User Control <MyControls:MyUserControl ...


7

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!


6

Make sure you put the user control into a subdirectory of {SharePointRoot}/Templates/ControlTemplates Put a Register element at the top of you page-layout <%@ Register TagPrefix="MyOwnPrefix" TagName="MyUserControl" Src="~/_controltemplates/MyProjectName/UserControl.ascx" %> and the refer to it where you need it like: <MyOwnPrefix:MyUserControl ...


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

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


5

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


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


5

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

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.


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

This may be unrelated, but did you put a proper URL in your project's Site URL field, and can you properly deploy and activate an empty solution from VS? I find that the designer files are not generated properly if my site URL is faulty (VS can't connect to it) or if I lack the permissions to deploy and activate a solution from within Visual Studio.


4

Fixed it by using the following code: private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/VisualWebPartProject/Export/ExportControl.ascx"; Note I just added 15 after CONTROLTEMPLATES.


3

Are you sure you're using a period and not a colon? <HRPortal.TopSection runat="server" id="topSection" /> should be <HRPortal:TopSection runat="server" id="topSection" /> Also, I have an example of a working control template that has an underscore before "controltemplates": <%@ Register TagPrefix="myPrefix" TagName="ToolBar" ...


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


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

OK, finally got. After long hours looking at the ugliest HTML/JS even written and short short periods of insanity, I add an idea that I don't totally like and it isn't the best, but at this point I don't f***ing care. I just want to get over this. So, I simple create a basic .aspx page with the follwing code: <%@ Page Language="C#" %> <%@ Register ...


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


2

In feature 1 have an elements.xml with: <?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Control Id="AdditionalPageHead" Sequence="90" ControlSrc="~/_CONTROLTEMPLATES/XXX/first.ascx" /> </Elements> In feature 2 have an elements.xml with: ...


2

You would be able to find the ASCX file in 14 root. typically .. C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES copy the JS files to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033 Update the ASCX file with reference to JS from "_layouts/1033/" folder like the ...


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 probably need to develop the following: A web part which generate html with A div which contains ajax to get the list of wiki pages, and when a page is selected ajax to get the anchors on that page jQueryUI to hide/show that div as a dialog Icon/link to activate jQueryUI A web service to respond to the above ajax calls A page layout to allow you to ...


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



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