I would find it very strange if the tridion:ComponentLink
tag you described in your question would resolve in a link with a query string, since that is not standard behavior of the Dynamic Linking Server Control.
Even if you would set the AddAnchor="false"
attribute to the value true
, you would not get a query string, but something like #1
added to your link url (where the number in question reflects the position of the Component Presentation on the Page that you are linking to).
So you either have customized the Dynamic Linking Server Control or I'm completely misunderstanding your question. But let me try to give something of an answer anyways, who knows it is spot on.
When using Broker queries I usually have it format my links with the TCM URI of the Component I want a detail representation of. For instance on my product lister page I list all products found via a broker query and that results in links like product.aspx?uri=tcm:6-317
.
On my product detail page (product.aspx) I have a user control which looks something like this:
<custom:ProductDetail ID="product_detail" runat="server"
template="tcm:6-322-32"
publication="tcm:0-6-1" />
The Template and Publication ID as set in there at publishing time to give the correct context.
Now in the code behind of this control I have the following which uses the supplied information (the attributes in the control and the uri in the query string) to get me the correct Component Presentation from the Broker:
protected void Page_Load(object sender, EventArgs e)
{
string templateUri = Attributes["template"];
string publicationUri = Attributes["publication"];
string componentId = HttpContext.Current.Request.QueryString["id"];
string componentUri = HttpContext.Current.Request.QueryString["uri"];
if (!string.IsNullOrEmpty(componentId) && string.IsNullOrEmpty(componentUri))
{
// tcm:0-x-1
int publicationId = int.Parse(publicationUri.Split('-')[1]);
componentUri = string.Format("tcm:{0}-{1}", publicationId, componentId);
}
using (ComponentPresentationAssembler cpa = new ComponentPresentationAssembler("tcm:0-0-0", Page))
{
ProductDetailPlaceHolder.Text = cpa.GetContent(componentUri, templateUri);
}
}
<
and>
characters which makes your question a lot more readable. It can also help to edit this question and see the changes I made for you.