sukesh
sukesh

Reputation: 2437

How to render a link with a query string in Sitecore

I am trying to generate a link field on to the page, in the below format

<a class="book__btn" href="https://oc.axis.com/rez.aspx?submit=&shell=CASGCF">
Book
</a>

aspx:

<sc:Link ID="lnkBook" runat="server" Field="Target URL"></sc:Link>
<sc:FieldRenderer ID="frBook" runat="server" FieldName="Target URL"></sc:FieldRenderer>

aspx.cs:

Item offerDetails = this.DataSource;
lnkBook.Item = offerDetails;
frBook.Item = offerDetails;

The pic shows my declarations using Rocks enter image description here

When the page is previewed, the button does not render at all. However, if I remove the text in the Query String field, it renders fine.

Upvotes: 0

Views: 2604

Answers (1)

Jim Noellsch
Jim Noellsch

Reputation: 714

The Sitecore Rocks interface is a little misleading for links because the applicable fields do not change based on the link type. Query String is only supported for internal links. If you want to add a query string to your external link, just add it directly to the Url.

Upvotes: 1

Related Questions