locked
Passing querystring with hyperlink RRS feed

  • Question

  • Hi,

    I have a visual web part created in VS 2010. In the visual web part, i have a button. when the user clicks on the button, i am redirecting the user to a Picture libraray(which is available as default in sharepoint itself). I am passing 2 querystrings while doing the redirect to the picture library.

    In the picture libraray, I have a hyperlink, which opens another page. I want to pass the 2 querystrings, which were received on the picture library with the Hyperlink available near the picture library.

    I have created a hyperlink, by using the calculated field. Currently the formula i have used for the calculated field is:

    [CODE]

    ="<a href=""http://SERVERIP/sitepages/Search Child.aspx?ImageId="&Title&""">Match Record</a>"

    [/CODE]

    How to achieve this?

    Thank you.

    Thursday, December 23, 2010 9:28 AM

Answers

  • sorry for delayed reply table with id as guid would be available in the view source see the sample 

    <table id="{C6444F02-E1A0-4A5E-B6F4-70BCCDC80508}-{A33E4FF9-83FA-454F-AB94-3F14A8F2069E}" summary="Posts" o:webquerysourcehref="http://blogs.edork.com/MikeGeyer/_vti_bin/owssvr.dll?CS=65001&amp;XMLDATA=1&amp;RowLimit=0&amp;List={C6444F02-E1A0-4A5E-B6F4-70BCCDC80508}&amp;View={A33E4FF9-83FA-454F-AB94-3F14A8F2069E}" width="100%" class="ms-listviewtable" border="0" cellspacing="0" cellpadding="1" dir="None"><tbody><tr class="ms-viewheadertr" valign="TOP"><th nowrap="" scope="col" class="ms-vh2"><div style="width:100%;position:relative;left:0;top:0;"><table style="width:100%;" sortable="" sortdisable="" filterdisable="" filterable="" name="ID" ctxnum="1" displayname="ID" fieldtype="Counter" resulttype=""

    the code you have find to find query string is fine you have to jus t use them to append the href of hyper link tag


     



    Best Regards, Ashutosh | My Blog Site
    Saturday, December 25, 2010 4:29 AM

All replies

  • It would not be possible using calculated column . what i can suggest is to add parameters in the xslt of the list view web part to accept querystring parameters and then add them to your column value using xslt.
    Best Regards, Ashutosh | My Blog Site
    Thursday, December 23, 2010 11:01 AM
  • Hi,

    I was thinking of using Query string URL filter web part. Will that solve my issue.

    Thank you

    Thursday, December 23, 2010 11:13 AM
  • query string filter web part are used to filter not appending text to your column values. my suggestion would still be to edit the xslt of your list view webpart. I assume you are using sharepoint 2010 else if you are using moss create a data view web part. 

     

    If you are not good in xslt and afraid of touching it i can suggest of using a javascript which runs on page load and captures the querystring and appends it to the inner html of the column which is containing the hyperlink


    Best Regards, Ashutosh | My Blog Site
    Thursday, December 23, 2010 11:40 AM
  • Oh great..

    Thank you very much for the reply.

    I am not good in xslt. Could you please suggest the javascript method and how to append the hyperlink which is available near the image with the querystring.

    I have 3 querystrings.

    Thank you

    Thursday, December 23, 2010 12:03 PM
  • providing you a pseudo code check the syntaxes

    Var table = this.document.getElementById("{29A18888-A043-4B59-B809-AD18E06C3D9C}-{DF3D9859-A1AC-42CE-AEE2-F54576D897A6}");// guid can be found from the view source of the page change it as it is in your case

    Var Rows = table.getElementByTagName("tr");

    for(i=1; i<= Rows.Length;i++)

    {

    Var cells = Rows [i].getelementbyTagname("td");

    //you must be knowing at which value this cell would be on your UI thats what i'm asuming

    var anchortag = cells[7].getelementbyTagname("a"); //put cell[x] where x is actual position on screen -1

    var urlLocation =  anchortag.href; 

    //add what ever you want to urllocation from query string 

    anchortag.href = newUrlLocation;

    cells[7].controls.add( anchortag); // if you wish you can use inner html as well google for that you would find ample help  

     

    }

     


    Best Regards, Ashutosh | My Blog Site
    Thursday, December 23, 2010 3:03 PM
  • Hi,

    Should the above code be used in content editor webpart javascript.

    I am really sorry, but i am not able to find the table guid, but i am able to find the list guid.

    I have these things, from the view source:

    [CODE]

    <script type="text/javascript">
          currentViewGuid = "{8E4EA50D-545D-4A3C-BFF5-2114F331C085}";
          InitImglibView("{B79F83DA-B1C1-421F-8009-D8655941BADF}","1033");
          vCurrentListUrlAsHTML = "http://serverip/sites/vdev/TPic/";
          vCurrentWebUrl = "http://serverip/sites/vdev";

        </script><tr><td>
    <table summary="TPic " o:WebQuerySourceHref="http://serverip/sites/vdev/_vti_bin/owssvr.dll?CS=65001&amp;XMLDATA=1&amp;RowLimit=0&amp;
    View={8E4EA50D-545D-4A3C-BFF5-2114F331C085}"

    class="ms-listviewtable" >

    [/CODE]

    I am not sure of where the cell is available, so is it possible to use the id of that

    Thank you

    Thursday, December 23, 2010 3:16 PM
  • HI,

    I found this link, which gets the querystring.

    http://blogs.edork.com/MikeGeyer/Lists/Posts/Post.aspx?List=c6444f02%2De1a0%2D4a5e%2Db6f4%2D70bccdc80508&ID=36

     

    How do i associate that with the "Match_Records" hyperlink, which is available in the table.

    Thank you

    Thursday, December 23, 2010 4:00 PM
  • HI Ashutosh,

    Any help on this?

    Thank you

    Friday, December 24, 2010 9:39 AM
  • sorry for delayed reply table with id as guid would be available in the view source see the sample 

    <table id="{C6444F02-E1A0-4A5E-B6F4-70BCCDC80508}-{A33E4FF9-83FA-454F-AB94-3F14A8F2069E}" summary="Posts" o:webquerysourcehref="http://blogs.edork.com/MikeGeyer/_vti_bin/owssvr.dll?CS=65001&amp;XMLDATA=1&amp;RowLimit=0&amp;List={C6444F02-E1A0-4A5E-B6F4-70BCCDC80508}&amp;View={A33E4FF9-83FA-454F-AB94-3F14A8F2069E}" width="100%" class="ms-listviewtable" border="0" cellspacing="0" cellpadding="1" dir="None"><tbody><tr class="ms-viewheadertr" valign="TOP"><th nowrap="" scope="col" class="ms-vh2"><div style="width:100%;position:relative;left:0;top:0;"><table style="width:100%;" sortable="" sortdisable="" filterdisable="" filterable="" name="ID" ctxnum="1" displayname="ID" fieldtype="Counter" resulttype=""

    the code you have find to find query string is fine you have to jus t use them to append the href of hyper link tag


     



    Best Regards, Ashutosh | My Blog Site
    Saturday, December 25, 2010 4:29 AM