Setting JSLink for XSLTListViewWebPart from code behind

I am adding an XSLTListViewWebPart from within a user contol code behind.  It adds fine, but I am not able to get it to resolve the JSLink file.  The js file works, as I've attached it to a list view web part in the web part properties and it works.
How do I set the JSLink property from the code?  I have set it on the view object and on the XsltListViewWebPart, but neither has any effect.  This has to be deployable from a wsp, so setting the value from the UI is not an option. 
XsltListViewWebPart FooterMenuListView = new XsltListViewWebPart();
  FooterMenuListView.ListId = linkList.ID;
  FooterMenuListView.ViewGuid = linkView.ID.ToString("B");
  FooterMenuListView.JSLink = "/_Layouts/15/FooterMenu.js";                                
  FooterMenuListView.BorderStyle = System.Web.UI.WebControls.BorderStyle.None;
  FooterMenuListView.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
  phFooterMenuList.Controls.Add(FooterMenuListView);
Any advice would be appreciated.

Hi,
Please try to use the code line below:
FooterMenuListView.JSLink = "/_layouts/15/FooterMenu.js";
Or you can upload the js file into a document library(JSLib) and use like this:
FooterMenuListView.JSLink = "~site/JSLib/FooterMenu.js";
JSLink also supports the following tokens, you can try it.
•~site
•~sitecollection
•~layouts
•~siteLayouts
•~siteCollectionLayouts
More information:
http://spdevlab.com/2013/07/07/5-facts-about-jslink-in-sharepoint-2013-you-might-not-know/
http://networkedblogs.com/GmSvo
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support

Similar Messages

  • [WPF] AutoCompleteBox: set parameters from code behind

    Hi,
    I'm using AutoCompleteBox from Codeplex.com
    I would set some parameters from code behind... 
    In XAML, I defined namespace:
    xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
    After using AutoCompleteBox:
    <toolkit:AutoCompleteBox
    x:Name="myAutoComplete"
    ItemsSource="{Binding Source={StaticResource DomainDataViewModel}, Path=SampleProperties, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
    SelectedItem="{Binding Name}"
    ValueMemberPath="Name"
    ItemTemplate="{StaticResource PropertyBoxItemTemplate}"
    MouseLeave="PropertyAutoCompleteBox_MouseLeave"
    >
    </toolkit:AutoCompleteBox>
    If I would set any parameter from code behind, in my.xaml.cs, I not found myAutoComplete, why?
    Thanks.

    >>I inserted the AutoCompleteBox as DataGridTemplateColumn.CellEditingTemplate.
    Then you cannot access it directly from the code-behind as I told you.
    >>I would apply a FilterCustom and a ItemFilter.
    You could handle the Loaded event for the AutoCompleteBox and set any of its properties in there:
    <toolkit:AutoCompleteBox
    x:Name="myAutoComplete"
    Loaded="myAutoComplete_Loaded"
    ItemsSource="{Binding Source={StaticResource DomainDataViewModel}, Path=SampleProperties, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
    SelectedItem="{Binding Name}"
    ValueMemberPath="Name"
    ItemTemplate="{StaticResource PropertyBoxItemTemplate}"
    MouseLeave="PropertyAutoCompleteBox_MouseLeave"
    >
    </toolkit:AutoCompleteBox>
    private void myAutoComplete_Loaded(object sender, RoutedEventArgs e)
    AutoCompleteBox myAutoComplete = sender as AutoCompleteBox;
    //set properties or do whatever here...
    myAutoComplete.ValueMemberPath = "Name";
    dynamic dataObject = myAutoComplete.DataContext;
    //access any properies of the data object in the DataGrid...
    How to do filtering is a completely other question that should be asked in a new thread though. It has nothing to do with your original question.
    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

  • Updating a Label content from code behind using dispatcher

    hi,
    I am trying to update a label's content from code behind.
    This part of the code is running in background worker. I wrote the following code to update a label's content:
    volumecontrol.Dispatcher.BeginInvoke(new Action(() =>
    volumecontrol.Content = volumeupdate;
     i tried using both BeginInvoke and Invoke but the application exits with the error:
    System.InvalidOperationException' occurred in WindowsBase.dll
    Using Invoke works when updating the UI from another thread but it not working in this case:
    Pls help.
    Thanks,
    Shaleen
    TheHexLord

    When you do that new action stuff you're capturing variables.
    If that means you grab a control's value across from outside the {} then you're trying to capture the variable on the background thread.  If that's some sort of control you're messing with then that will cause a problem as they have thread affinity.
    Because you don't want to be blocking the UI thread at all you should use BeginInvoke rather than Invoke.
    To explain this clearly - and provide a way you could use to explore what's going on and learn  - we need a separate thread which can be done using Task.Factory.StartNew.
    This bit of code allows you to put code onto a background thread:
    Task.Factory.StartNew(() =>
    // On a separate thread to the UI here
    Create a new solution, add a textBlock and Button:
    <StackPanel>
    <TextBlock Name="tb"/>
    <Button Name="btn" Click="btn_Click">Change the text</Button>
    </StackPanel>
    Then in the button click you can play around with what's going on.
    Just to be clear.
    That textblock is a control and it is created on the UI thread.
    To get from that task thread back to the UI thread you should use Dispatcher.BeginInvoke.  With no control name.
    Let's start with a broken piece of code:
    private void btn_Click(object sender, RoutedEventArgs e)
    Task.Factory.StartNew(() =>
    string thingummy = tb.Text + "Banana";
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    When you click the button it'll error because when you access tb.Text there you do so on a background thread and tb has thread affinity.
    This, however, will work OK.
    Task.Factory.StartNew(() =>
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = tb.Text + "Banana"; }));
    That's OK because the Action runs on the UI thread where tb was created and all is good.
    Anonymous methods and actions capture variables ( you can google that for more info ).
    If you wanted to use a variable which was created on the background thread you can set it here:
    Task.Factory.StartNew(() =>
    string thingummy = "banana";
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    or here
    string thingummy = "banana";
    Task.Factory.StartNew(() =>
    Dispatcher.BeginInvoke(new Action(() => { tb.Text = thingummy; }));
    They both work.
    They are not accessing properties of a UI control because you're just setting the variable to a string.
    All of which means you could have a variable in your code which is set to volume or whatever that is from your control  ON THE UI THREAD and then modify that variable on the background thread.  Variables do not have thread affinity.  A
    double, string or whatever isn't a control.
    And this approach might well be more convenient.
    Hope that helps.
    Recent Technet articles:
    Property List Editing ;  
    Dynamic XAML

  • Detect current device channel from code behind

    From
    MSDN article about device channels:
    Also, device channels can set a JavaScript variable called effectiveDeviceChannel that contains the current channel alias. This variable can be used to show which channel is currently being used.
    Is there similar variable, that could be used in code behind (in C#), to determine which channel is currently used?

    You can use DeviceChannelPanel in your web part...
    For e.g. the following in a visual web part will render only to a channel that is targetted for tablets.
    <Publishing:DeviceChannelPanel runat="server" ID="pnlTab" IncludedChannels="Tab">
        You can see this tab devices.
    </Publishing:DeviceChannelPanel>
    From code behind, you can create a device channel panel dynamically and add contents to it.
    e.g.
                LiteralControl l = new LiteralControl();
                l.Text += "Sample content for tablets";
                DeviceChannelPanel dp = new DeviceChannelPanel();
                dp.Controls.Add(l);
                dp.IncludedChannels = "Tab";
                MyPanel.Controls.Add(dp);

  • How to trigger updateMarker for TextEditor from code

    I'm making my own marker. But when I change document programmatically, I couldn't trigger updateMarker. So markers're indexs don't change.Markers has not showed correctly. How to trigger updateMarker for TextEditor from code?

    Hi Viren,
    Glad that your problem is resolved.
    Help.Sap.com is the best reference: http://help.sap.com/saphelp_nw04/helpdata/en/b2/e50138fede083de10000009b38f8cf/frameset.htm
    Also check the "How-To" docs in https://www.sdn.sap.com/irj/sdn/developerareas/bi
    Bye
    Dinesh

  • Please help: unable to set preferences for planning from workspace.

    Hi Experts,
    unable to set preferences for planning from workspace.(file--->preferences----->planning), when doing this task prompts " An Error occured" preferences works fine with other components IR, FR, WEB ANALYSIS.problem is only with the planning.
    1) i restarted the workspace and planning services but even then the same issue.
    Please help me out on this issue.
    Thanks.

    Hi,
    Do you get the same problem if you access planning directly ? http://<planningmachine>:8300/HyperionPlanning/
    Just trying to understand if it related directly to planning and maybe you will get a different error message.
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Raiseevent from code behind

    I need to use the PCC to update a secondary portlet at a specific time during the postback of a click event. Can I use the PCC to raise an event from the code behind file?

    I'm afraid you cannot do this - the PCC exists solely on the client so must be called from the client, not the server. What you can do is include some javascript to handle this instead. One simple solution would be to add the script block
    <script defer language="JavaScript">document.PCC.raiseEvent(...)</script>
    This however will only work in IE. If you want cross browser support then you will have to register for your own portlets rerender event, then upon a rerender you must check some condition which you set in the codebehind (i.e. the text in a hidden element) and raise the PCC event accordingly.

  • Location for login.aspx code behind?

    I added a Login.aspx.cs file in the Server Project with some code in
    Page_Load() I need to implement, and edited the first line of login.aspx this way:
    <%@ Page Language="C#" CodeBehind="Login.aspx.cs" Inherits="Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase" %>
    What I added, exactly, are the Language and CodeBehind
    properties.
    But when I deploy and run the application, I get this error:
    The type 'Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase' is ambiguous: it could come from assembly 'C:\testing\Sandbox\bin\Microsoft.LightSwitch.Server.DLL' or from assembly 'C:\testing\Sandbox\bin\Application.Server.DLL'.
    Please specify the assembly explicitly in the type name.
    I understand this is because Login.aspx.cs already exists in some assembly.
    Is there any way to Access Login.aspx code behind?
    If not, how can I add my own login page to an HTML Client App without losing the already configured Forms security, roles, permissions, etc.?
    thanks.
    Nicolás.
    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to
    "Mark as Answer". This will help other people find answers to their problems more quickly.

    Josh:I tried your suggestion, edited Login.aspx like you said, and the code for Login.aspx.cs converted from vb is this:
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security;
    using Microsoft.LightSwitch;
    using LightSwitchApplication;
    using LightSwitchApplication.Helpers;
    namespace LightSwitchApplication
    public partial class Login : Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase
    protected void Page_Load(object sender, EventArgs e)
    AuditHelper.CreateAuditTrailForLogin();
    public Login()
    Load += Page_Load;
    As you can see, all I want to do is call AuditHelper.CreateAuditTrailForLogin()
    on Page_Load()
    But I'm getting this exception, wich is obvious what it means, but I don't know how to fix. Does it mean we're overriding Server generated Page_Load() so I have to write all the code that handles authentication?:
    The method or operation is not implemented.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.             
    Exception Details: System.NotImplementedException: The method or operation is not implemented.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.                  
    Stack Trace:
    [NotImplementedException: The method or operation is not implemented.]
    LightSwitchApplication.Login.Page_Load(Object sender, EventArgs e) +36
    Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase.OnLoad(EventArgs e) +90
    System.Web.UI.Control.LoadRecursive() +71
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
    Any help appreciated.
    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to
    "Mark as Answer". This will help other people find answers to their problems more quickly.

  • How to set password for photos from home screen? Please help.

    Hi,
    Can anyone pls help to set password for my Iphone 4s.
    My friends/family often use my phone for gaming purpose. I don't want them to see my photos/gallery/videos.
    How can I protect my personal things from others?
    Thnx.
    Rgds.

    There is no way to set a password for photos. You could upload all of your photos to something like DropBox, then sign out of the app. Or, you could only let people you trust to respect your privacy touch your phone.

  • Newbie: Trying to get data  from Code Behind file to HTML file.

    Greetings,
    I am trying to use the opener link adaptive tag to open a specific page. I have the Object ID, and classID as variables in my class in my class file, but I do not know how to get that data into the opener link which is on the html page.
    Should I be using session variables? If so how, I am a newbie.
    Does anyone know how?
    Thanks.

    Kinda depends on your flavor/need/preference. I've done it...
    * Using session variables and just writing to the page in script blocks. Not preferred in .NET-land, but definitely more of the fast/traditional ASP style. Use sparingly and with caution. Be really careful about VS.NET totally destroying your tags. It seems to love doing that (as an aside - HUGE thank-yous to the BEA engineers who altered the tags to consistenly use lower case. Really. I can't thank you enough. :) )
    * Using label controls and then just populating the label with the formatted adaptive tag (this can work well)
    * One of our guys did a really simple/elegant server control that takes arguments for the objectid, classid, etc. Nice for creating things repeatedly server-side and gets you by the HTML, quotes, etc. all over the place. Nice as it also consolidates the tag in a single place you can alter once.
    For session variables, you'd just do something like...
    <%
    '//in your code-behind
    Session("myClassID") = 18
    Session("myObjectID") = 12345
    %>
    <!-- in your aspx file -->
    <pt:standard.openerlink xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:objectid='<%=Session("myObjectID")%>' pt:classid='<%=Session("myClassID")%>' pt:mode='2' target='myWindow' onclick=window.top.open('','myWindow','height=800,width=700,status=no,toolbar=no,menubar=no, location=no');>Adaptive Tags Made This Easy - Click to Open My Awesome Document</pt:standard.openerlink>
    That help?
    Personal style, I would try to avoid using session, etc. directly on your ASPX file. I'd go with writing out the HTML through labels, data lists, etc. in your code-behind.
    Thanks,
    Eric

  • I have an iPad 2 and receive e-mail through internet connection. When I delete e-mails, and clear my Trash folder, they re-appear. Setting are for remove from server when moved from Inbox. Any idea what I can do to actually delete them?

    I have an iPad 2 and receive e-mail through regular internet connection. Lately, when I delete e-mails, and clear my Trash folder, they re-appear, downloaded anew from the server and marked as unread. My e-mail Advanced Settings are selected for "Remove from server when moved from Inbox." Even when I access the e-mail accountfrom my desktop and delete the e-mails, the re-appear on my iPad. Does anyone have any idea what is causing this and what I can do to actually delete them?

    Sounds like you are looking in the wrong Administrative Group container which is why you are seeing your Exchange 2010 servers in there.
    When you install Exchange 2003 only you will see a container named by default as "CN=First Administrative Group" container. But this could be named anything if you changed the Organization Name on the installation when you installed the first
    Exchange 2003 server into the domain/forest. 
    You will notice that when you install Exchange 2010 part of the AD setup is to create a new configuration container and is named by default "CN=First Administrative Group (FYDIBOHF23SPDLT)".
    So it sounds like you are not looking in the right location within ADSIEdit. 
    You may find the following article also helpful for this issue which is the same resolution:
    http://blogs.technet.com/b/sbs/archive/2012/05/17/empty-cn-servers-container-causing-issues-with-public-folders-on-small-business-server-2011.aspx
    I recommend though that you ensure your Exchange 2003 servers are fully uninstalled or no longer present in your environment before you go deleting the Servers container though.. The following Microsoft article will help with this:
    http://technet.microsoft.com/en-gb/library/gg576862(v=exchg.141).aspx

  • Transferring set-up for Mail from iMac to iBook

    I just switched from AOL to Mail on my iMac and would like to have the same setup on my iBook. How can I do this without building everything from scratch a second time? I'm not sure where to look for the preferences or whatever that is saved for my Mail configuration. Any help?
    Thanks,
    Joanne

    Joanne,
    One easy way to make the transfer, unless the Mail folder is of extreme size, is to Network the iBook with the iMac. More on this in a moment.
    What you want to do, by network, target disk, or burned media, is REPLACE the com.apple.mail.plist file (Home/Library/Preferences), and the Mail folder (Home/Library/Mail ) on the iBook with a copy of the same files from the iMac. Once you have done this, launch Mail on the iBook, and you will be set. The same can be done with the Address Book (Home/Library/Application Support/Address Book.
    To do this while in direct network link do the following:
    On the iMac, click on System Preference icon in the Dock, and choose Sharing. Next place a check mark in box beside Personal File Sharing.
    Now, on the iBook, open a Finder window, and click on the Network globe in the Sidebar, and you will see your iMac listed. Double click on the iMac icon, and when prompted enter the administrator password for the iMac. At that point choose to connect to your Home folder on the iMac, and then an Icon for that home folder will mount on the iBook. Open it the same as you would open the HD, and then open the HD on the iBook, and locate the files you wish to replace with copies of those on the iMac.
    Hope this helps.
    Ernie

  • FRDM-K64F set the realtime clock from code?

    Hi, all!
    I have read the docs about rtc.time in the jwc_properties.ini file. This works ok when installing, but when the device resets or power is cycled, the clock will be incorrect. Since my app is communicating with a server, it would be simple to get the current datetime from the server. But I have not found any way to set the current clock other than the jwc_properties.ini file. Is there a way I can do this in my app? Or can my app write to the jwc_properties.ini file and then restart itself?
    Thanks!

    Hi!
    Actually you can change the value of the property using the following method:
    Settings.setStringProperty("rtc.time", "2016:01:01:00:00:00");
    Your application shall exit after invoking this line in order for the property to be written into the file. Please note that the rtc is only updated from the property during power-up or reset of the MCU. So that the new time is not applied when your application restarts, you need to force MCU to restart. And because Java APIs are limited on k64 there seem to be no way to initiate that from the application
    Regards,
    Andrey

  • How To Force Open Document In Edit Mode From Code-Behind (Chrome and Firefox)?

    Hello,
    Currently I am developing an IHttpHandler which at the should redirect the user to an Edit mode of a document located in a Document Library.
    The Problem is that in Firefox and Chrome it downloads the document in the temp folder. In IE it works as expected.
    The following code is used for the redirection:
    SPUtility.Redirect(urlOfTheNewDocument, SPRedirectFlags.Trusted, context);

    Hi,
    Please try to use IE Tab.
    Chrome IE Tab:
    https://chrome.google.com/webstore/detail/ie-tab/hehijbfgiekmjfkfjpbkbammjbdenadd?hl=en 
    Firefox IE Tab:
    https://addons.mozilla.org/en-us/firefox/addon/ie-tab/
    Here is a similar thread for your reference:
    http://stackoverflow.com/questions/14455212/how-to-open-sharepoint-files-in-chrome-firefox
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • FCE-4 ingestion set up for material from a Sony TG3E AVCHD camera?

    Hi
    I have a Sony TG3E PAL AVCHD camera and want to cut my material with FCE4 on my intel macbook pro. How should I set up easy set up to ingest the material? There are 3 record settings I can use on the camera: HD FH (1920 x 1080), HD HQ and HD LP (1440 x 1080 and lowest quality). All are AVCHD.
    Do I ingest at:
    HD - 25 fps- HDV Apple Intermediate Codec 1080i50 or
    HD - 25 fps - AVCHD Apple Intermediate Codec 1440 x 1080i50 or finally
    HD -25 fps - AVCHD Apple Intermediate Codec 1920 x 1080i50?
    The camera generates 5.1 surround sound but says nothing about what KHz sampling rate the sound is.
    Many thanks for any help
    John

    Thank you.
    In Easy set up I am confused about which format to click.
    In the camera manual it says the video compression format is AVCHD HD, recording format AVCHD 1080i50 and video signal PAL.
    Now that you have told me I can shoot on 1920X1080 which format should I choose:
    apple intermediate codec (my vote) or PAL or HD?
    I put 25fps in rate - is that correct?
    Many thanks.

Maybe you are looking for