Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have enabled attachment in my custom webpart like below.

<xsl:element name="SharePoint:AttachmentsField">
      <xsl:attribute name="runat">server</xsl:attribute>
      <xsl:attribute name="ListId">
             {} </xsl:attribute>
      <xsl:attribute name="FieldName">Attachments</xsl:attribute>
      <xsl:attribute name="ControlMode">Display</xsl:attribute>
      <xsl:attribute name="Visible">true</xsl:attribute>
      <xsl:attribute name="ItemId">
          <xsl:value-of select="@ID"/>
      </xsl:attribute>

How can I add target="blank"?

share|improve this question
add comment

1 Answer

I've used jQuery in the past to find the link and add the attribute

$("a.yourclass").attr("target","_blank");

make sure to narrow it down to your items, otherwise all links will open in new windows

HTH

share|improve this answer
    
hm... nice tips.Tha bUT It seems i would have to add an id to itself. How did you get to your selector? –  naijacoder Jan 23 '12 at 7:30
    
simplest way is to wrap you items with a div tag, and give that an ID, like $("#myDiv a").attr, or give each of your hyperlinks a unique class, and that can be used like $("a.yourClass").attr –  David Lozzi Jan 23 '12 at 13:13
    
David how do i add the class though: An element css class or ID doesn't exist by default. How did you go with yours.Please elaborate. This is my output below. <tr id="{0052E8DD-52C3-4C5B-9052-9C4D69210C0E}"> <td class="ms-vb"> <span dir="ltr"> <a href="/sites/Intranet/Comm/Lists/Co/Attachments/1/indicator.gif" onclick="DispDocItemExWithServerRedirect(this, event, 'FALSE', 'FALSE', 'FALSE', '', '1', '');return false;" onmousedown="return VerifyHref(this, event, '1', null, '');return false;" tabindex="1">indicator.gif</a> </span>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr> –  naijacoder Jan 27 '12 at 4:11
    
I have actually managed to add the target="blank" but when i click it it doesn't open in a new window –  naijacoder Jan 27 '12 at 4:57
    
Does it open in a new tab? And it should be target="_blank" –  David Lozzi Jan 27 '12 at 12:20
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.