How to link Title in object model

I am displaying all blog posts Titles on post page. But I want to link those post so that user should click on that.
Below is my code
<label id="labelHTML"></label><script type="text/javascript">
var listoperation =null;
var clientContext = null;
var web = null;
ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
function Initialize()
clientContext = new SP.ClientContext.get_current();
web = clientContext.get_web();
var list = web.get_lists().getByTitle("Posts");
var camlQuery = new SP.CamlQuery();
var q = '<View><RowLimit>5</RowLimit></View>';
camlQuery.set_viewXml(q);
this.listItems = list.getItems(camlQuery);
//var listId = _spPageContextInfo.pageListId;
//var itemId = parseInt(GetUrlKeyValue('ID'));
clientContext.load(listItems, 'Include(DisplayName,Id,testchoice)');
clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess),
Function.createDelegate(this, this.onQueryFailed));
function onListItemsLoadSuccess(sender, args) {
$('#labelHTML').html('');
var listEnumerator = this.listItems.getEnumerator();
//iterate though all of the items
while (listEnumerator.moveNext()) {
var item = listEnumerator.get_current();
var title = item.get_displayName();
//var id = item.get_id();
document.getElementById('labelHTML').innerHTML += title.toString() + "<br />";
function onQueryFailed(sender, args) {
alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}</script>​
plz help.

you have everything to make the link. 
web.get_serverRelativeUrl()
+ "/Lists/Posts/Post.aspx?ID=" + id
-tom daly

Similar Messages

  • How to impersonate in client Object model?

    Hii,
    I am using client Object Model Programming in WCF service which is hosted on IIS. I have created separate APP pool in IIS which has windows authentication enabled. This App pool account will be dealing with the sharepoint server. Now I am stuck at one point.when
    I upload a file, I want to set the actual logged in user as the author or editor of the file not the app pool account. Means I want to impersonate. How can I do this?
    I have visited this link
    http://stackoverflow.com/questions/949340/getting-networkcredential-for-current-user-c but didnt work out as expected. Can any one provide some input please?
    Thanks and Regards,
    PraTech

    Hi I have tried both the options.
    The first option works fine.It impersonates all the user calls. But I wan to use serviceaccount and useraccount at times. Coule you please look in the below code and let me know why it is failing?
    teh problem is described below.
    I have an IIS app pool account to interact with the sharepoint server. but there are cases when I need to use the logged in users credentials instead of appPool account when doing some operations like uploading a document. So I decided to impersonate. I
    added the below code in the web.config file so that all  server calls are impersonated.
    <serviceBehaviors>
    <behavior name="ImpersonatedBehavior">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="false" />
    <serviceAuthorization impersonateCallerForAllOperations="true"
    </behavior >
    </serviceBehaviors>
    and then i have a file uplaod method as given below
    public string UploadFile(objDocument)
    using (ClientContext clientContext = new ClientContext(objDocument.workspaceUrl))
    Site site = clientContext.Site;
    clientContext.Load(site, s => s.Url); //need url for some reasons
    clientContext.ExecuteQuery(); //Exception :UnAuthorized
    File.SaveBinaryDirect(clientContext, urlpart+ "/" + FileName, stream, true);
    clientContext.ExecuteQuery();
    the very first call to ExecuteQuery was throwing exception "UnAuthorized".actually  the user has full control on the particluar workspace.then I add the below piece of code ( just before the clientContext object initilaiztion )so that clientcontext
    object is created using the serviceAccount(appPool Account). then it was working fine. but failing at File.SaveBinaryDirect() method call.
    WindowsImpersonationContext ctx = null;
    if (!WindowsIdentity.GetCurrent().IsSystem)
          ctx = WindowsIdentity.Impersonate(System.IntPtr.Zero);
    using (ClientContext clientContext = new ClientContext(objDocument.workspaceUrl))
      Site site = clientContext.Site;
      clientContext.Load(site, s => s.Url); //need url for some reasons
      clientContext.ExecuteQuery();  //Working Fine now.
    if (ctx != null)
    ctx.Undo();// co'z while uploading the file we dont need appPool account.but need users account.
    File.SaveBinaryDirect(clientContext, urlpart+ "/" + FileName,  stream, true);
    clientContext.ExecuteQuery();//Exception
    finally
                        if (ctx != null)
                            ctx.Undo();
    Now it is throwing exception at the File.SaveBinaryDirect() saying "401:Unauthorized".

  • How to connect to Indesign object model from VBA (Macintosh_Office)?

    In PC it was: find/load tlb-file and chek box to activate. In Mac i don't see any tlb-files, so can't add this lib to VBA reference. Can i do this at all?

    Hi,
    According to your description, you might want to connect SharePoint Online environment using Client Object Model.
    For the authentication, you can take a look at the link below with code demo provided:
    http://www.vrdmn.com/2013/01/authenticating-net-client-object-model.html
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • How can I use Diagnostics Object Model APIs?

    Hi.
    In the Internet Explorer DevCenter page I could reach a very interesting section about developer APIs. In particular there is a section devoted to the Diagnostics
    Object Model API. This is something very cool I think but the problem is that I couldn't find a way to use such APIs.
    There are many pages about methods, properties that one can use, but absolutely no page where it is possible to download something or understand how to use these tools. For example consider the DiagnosticsGlobalScope object
    used across this API to retrieve references to all methods and other objects for diagnostics: I tried typing it in F12 console, but did not succeeded in getting a reference to a valid object.
    How am i supposed to use this API?

    Hi,
    As the issue is specific with IE development, you may contact Microsoft IE Dev center for further assistance on the issue:
    Contact - Internet Explorer Dev Center:
    http://social.msdn.microsoft.com/Forums/ie/en-US/home?category=iedevelopment
    Please revert for any clarification on this or any Windows issue. We will be glad to help you.
    Roger Lu
    TechNet Community Support

  • Matrix  LinkedButton how to link to different object?

    I have a matrix , i would like to like specific colum Say column1 to
    multiple object, meaning every row will link to different object, is that possible?
    I know how to link a coulmn to a Linked object
    oColumn = oColumns.Item("column1")
    oLink = oColumn.ExtendedObject
    oLink.LinkedObject = SAPbouiCOM.BoLinkedObject.lf_GLAccounts
    what i want is based on certail condition
    row1, coulumn1 link to  lf_Invoice
    row2, coulumn1 link to  lf_PurchaseInvoice
    Is that possibel?

    i think u can use Item Event Before Action=True to solve it
    code below is what i'm using
    If pVal.ColUID.Equals("DocNum") And pVal.EventType = SAPbouiCOM.BoEventTypes.et_MATRIX_LINK_PRESSED Then
             sObjectType = oGrid.DataTable.Columns.Item("ObjType").Cells.Item(pVal.Row).Value
             oEditTextColumn = oGrid.Columns.Item("DocNum")
             oEditTextColumn.LinkedObjectType = sObjectType
    End If

  • Client Object Model in Visual Webpart

    Hi
    I am new to Client Object Model.I've to create a visual web part in SharePoint 2013 via Client Object Model using
    SandBoxed solution.
    i did following.
    1-Created empty sharepoint project
    2-added two dlls for Client Object Model in the project
    Microsoft.SharePoint.Client
    Microsoft.SharePoint.Client.Runtime
    3-in the visual webpart .ascx file i just created asp label as  below
    <asp:Label ID="label1" runat="server"></asp:Label>
    4- in the visual webpart .cs file i write a client object model code to show title items in the label from the "Test" list as below.
    5-when i deploy the code it deploys successfully,but when i try to insert this web-part on to the page it shows errors
    as below.
    Please tell me what am i doing wrong.Urgent help required.

    Yes,deployed as sandbox solution.Actually i want to create a visual webpart in Sharepoint 2013 using Client Object Model. How can i do this,i followed below steps.
    1-Created empty sharepoint project
    2-added two dlls for Client Object Model in the project
    Microsoft.SharePoint.Client
    Microsoft.SharePoint.Client.Runtime
    3-in the visual webpart .ascx file i just created asp label as  below
    <asp:Label ID="label1" runat="server"></asp:Label>
    4- in the visual webpart .cs file i write a client object model code to show title items in the label from the "Test" list as below.
    using Microsoft.SharePoint.Client;
    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls.WebParts;
    namespace SharePointProject2.VisualWebPart1
        [ToolboxItemAttribute(false)]
        public partial class VisualWebPart1 : WebPart
            // Uncomment the following SecurityPermission attribute only when doing Performance Profiling on a farm solution
            // using the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
            // for production. Because the SecurityPermission attribute bypasses the security check for callers of
            // your constructor, it's not recommended for production purposes.
            // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
            public VisualWebPart1()
            protected override void OnInit(EventArgs e)
                base.OnInit(e);
                InitializeControl();
            protected void Page_Load(object sender, EventArgs e)
                ClientContext context = new ClientContext("http://spsiteURL");
                List testList = context.Web.Lists.GetByTitle("Test");
                CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
                ListItemCollection items = testList.GetItems(query);
                context.Load(items);
                context.ExecuteQuery();
                foreach (ListItem listItem in items)
                    label1.Text = label1.Text + ", " + listItem["Title"];
    If this is not the correct way then how can i  use client object model to get sharepoint list items.Please mention.

  • Not able to use Client Object Model in Visual Webpart SandBox Solution?

    Hi,
    I am trying to use client object model in visual webpart in sandbox solution but i am getting unexpected error but if i remove client object model code webpart works fine?
    any help is appreciated.
    Regards,
    Gaurav Verma

    Check this article for your answer
    How to leverage the Client Object Model in a Sandbox Visual Web Part
    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    INSQLSERVER.COM
    Mohammad Nizamuddin

  • Using Component Object Model+ (COM+) in webdynpro

    Dear friends,
    How can I use Component Object Model+ (COM) in webdynpro? Is it feasible to use COM to access SQL Server 2005 Database.
    Thanks and Regards,
    Tarani

    Hello Brian Tyler
    I followed your instruction but I ran into another problem ~
    I can't find the COM with the control
    on this website
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersg...
    I have found this section that I want to use:
    Modifying the Contents of the Taskbar
    Version 4.71 and later of Shell32.dll adds the capability to modify the contents of the taskbar. From an application, you can now add, remove, and activate taskbar buttons. Activating the item does not activate the window; it shows the item as pressed on the taskbar.
    The taskbar modification capabilities are implemented in a Component Object Model (COM) object (CLSID_TaskbarList ) that exposes the ITaskbarList interface (IID_ITaskbarList ). You must call the HrInit method to initialize the object. You can then use the methods of the ITaskbarList interface to modify the contents of the taskbar.
    but I can't seen to find it.
    Oh and I visited your blog, it is awesome, the nano car article is cool
    thanks for your help
    Jimmy

  • ESTK Indesign Object Model

    Hi All,
    How to deal with InDesing Object Model in ESTK? Is anybody have any manual or reference?
    I am having problem to understand classes (singular and plural) and method. I have not found any reference in Java script Tool Guide.
    Please guide me.
    Thanks,
    Mon

    Mon,
    The distinction between singular and plural is an artificial one. The plural refers to a class of objects, the singular to inividual objects. Take page, for instance. Under pages you see methods such as add(). Under page you see methods (move(), remove()) and properties (length, characters). But page doesn't exist as an object: instead you address an item in the class. Some examples:
    Relating to the whole class:
    myDoc.pages.add()  // add a page to the document's pages collection
    myDoc.pages.length  // the number of pages in the document
    Relating to individual pages:
    myDoc.pages.item(0).textFrames  // the text frames on the first page
    myDoc.pages.item(1).groups  // the groups on page 2
    As tomaxxi mentioned, Jongware files are very good. For some more explanation of the object model, see http://oreilly.com/catalog/9780596802523/
    Peter

  • How to get all previous versions page contents of a publishing page using SharePoint Client Object Model 2010

    How to get all previous versions page contents and other field values of a publishing page using SharePoint Client Object Model 2010?
    Thanks,
    Osmita

    Hi Osmita,
    Greetings.
    Here are the links that helps you. It has code attached to it.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/a0d2ab40-99ba-4368-8505-1dc559ef6469/get-content-of-previous-version-of-page-sharepoint-2010?forum=sharepointgeneralprevious
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/faaf419f-997e-4150-9911-48cc375c3b46/how-to-get-previous-published-versions-of-publishing-pages-in-sharepoint-2010?forum=sharepointdevelopmentprevious
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Sharepoint authentication Client object model for direct links

    We have a Sharepoint 2010 site and another website [ASP.Net Web API 2] which uses Client object model to get data from Sharepoint, this is an intranet environment.
    The Client object model part of it is working fine, if any user logs in, it works with that user credentials. But when a user tries to access a direct SP link, ex: a link to a document from a document library, it pops up a credentials window.
    How to get rid of this pop up window, or how to set the authentication for the entire server when the user logs in to our web api.

    Hi,
    The prompt for credential can be seen as a behavior by designed for the sake of safe and there are no solutions to avoid it at this moment per my knowledge. 
    Here is a similar thread will provide more information:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/85b5d22a-88ed-4975-8de9-1d65df293aeb/avoiding-prompting-for-authentication-when-accessing-the-aspx-page-in-layouts-folder-from-my?forum=sharepointdevelopmentprevious
    Thanks
    Patrick Liang
    Forum 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]
    Patrick Liang
    TechNet Community Support

  • How to upload a document with values related to document properties in to document set at same time using Javascript object model

    Hi,
          Problem Description: Need to upload a document with values related to document properties using custom form in to document set using JavaScript Object Model.
        Kindly let me know any solutions.
    Thanks
    Razvi444

    The following code shows how to use REST/Ajax to upload a document to a document set.
    function uploadToDocumentSet(filename, content) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/add(url='" + filename + "',overwrite=true)?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': content,
    processData: false,
    timeout:1000000,
    'headers': {
    'accept': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val(),
    "content-length": content.byteLength
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err,textStatus,errorThrown) {
    dfd.reject(err);
    return dfd;
    Then when this code returns you can use the following to update the metadata of the new document.
    function updateMetadataNoVersion(fileUrl) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/getbyurl(url='" + fileUrl + "')/listitemallfields/validateupdatelistitem?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': JSON.stringify({
    'formValues': [
    '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
    'FieldName': 'Title',
    'FieldValue': 'My Title2'
    'bNewDocumentUpdate': true,
    'checkInComment': ''
    'headers': {
    'accept': 'application/json;odata=verbose',
    'content-type': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val()
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err) {
    dfd.reject(err);
    return dfd;
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • How to get windows form object of a MMC snapin node using MMC automation object model

    Hello,
    I am using automation object model for an existing mmc file and just trying to traverse all nodes of it. And i am able to do so.
    My query is : how can i get the access of windows form object of a particular node . Windows form is present in result pane of a node, i want to get access of that so that i can perform some automation on that form.
    http://msdn.microsoft.com/en-us/library/aa815049(v=vs.85).aspx
    I found that if OCX control is in result view of any node, then "view object -> control object property" returns
    the automation interface supplied by the control in the result view. 
    However, if result view is HTML view then how to get the automation interface of that result
    view.
    Thanks in advance,
    Sumit

    Hi Sumit,
    I read the link you provide above. It seems that when you want to achieve your target by using MMC automation
    object model, you need to use codes. Based on the programming language, if use VB, I suggest you post the question in
    VB Forum. If you want to use C#, may post in
    C# Forum.
    In addition, there is an answered question, may help you to find the correct forum.
    MMC development forum?
    http://social.microsoft.com/Forums/en-US/3796a8e9-674e-4da0-a40e-4e4b69575c8e/mmc-development-forum?forum=whatforum
    Since, it’s more related to development. We may can’t provide some more detailed information. Thanks for your
    understanding.
    Hope this helps.
    Best regards,
    Justin Gu

  • How to execute powershell .ps1 file using sharepoint object model

    Hi All,
    Can some one please guide me, how can i execute .ps1 file with arguments using c# under sharepoint object model?
    MercuryMan

    Code example:
    RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create();
    Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration);
    runspace.Open();
    RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace);
    Pipeline pipeline = runspace.CreatePipeline();
    //Here's how you add a new script with arguments
    Command myCommand = new Command(scriptfile);
    CommandParameter testParam = new CommandParameter("key","value");
    myCommand.Parameters.Add(testParam);
    pipeline.Commands.Add(myCommand);
    // Execute PowerShell script
    results = pipeline.Invoke();
    See these links for more information:
    http://stackoverflow.com/questions/527513/execute-powershell-script-from-c-sharp-with-commandline-arguments
    http://www.codeproject.com/Articles/18229/How-to-run-PowerShell-scripts-from-C
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • How do I find a previously passcode to link a wireless keyboard (Model A101urs6) to a Mac Power Book G4 running 10.5.8.  The keyboard was linked at one point in the past, but then not used.  When I am trying to hook it up now, it requires the passcode.

    How do I find a previously passcode to link a wireless keyboard (Model A101urs6) to a Mac Power Book G4 running 10.5.8.  The keyboard was linked at one point in the past, but then not used.  When I am trying to hook it up now, it requires the passcode.  Where can I find this, or is there a general number I can use?

    Hello, and welcome to Apple Support Communities!
    Try entering four zeroes.

Maybe you are looking for

  • Servlet Registration/Forwarding Question in WLS 5.1 SP8

              Here is my problem....           The request coming to WL server is http://localhost:7003/?id=11           How do I configure weblogic so that it sends the all these requests(starting with           a '?')           to a particaular Servlet

  • Flash Player installer isn't displaying properly in Win7 - how to fix?

    I'm running a new installation of 64-bit Win7 with IE11 (seems to be a 32-bit IE).  I'm trying to install Flash Player but the install screen isn't working properly. It looks fine until I get to the bit where I choose my update option, and then when

  • Updating Sybase using jConnect5.5

    Can anyone of you help me out ? Here is my code and following the code is the error I'm getting while compiling the code. //CODE import java.sql.*; import com.sybase.jdbc2.jdbc.*; import java.util.*; import com.sybase.jdbcx.*; public class dataBase p

  • Refreshing of a report

    I have built up a report which has some Oracle Portal links on some of the columns. Each link displays a form with relevant data. I can update some of the columns by changing the values displayed on the form. It is getting updated successfully. Now t

  • Upgrade to Airport Utility 6.2 problems

    imac running 10.7.5. network off comcast modem to airport extreme base station with 2 airport express as extenders. controlled the expresses with airport utility 5.6. had airport 6.1 as well. now ran the upgrade to 6.2 and can't control any of the ai