For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
-
AbleMods
- Master Yoda
- Posts: 5170
- Joined: Wed Sep 26, 2007 5:47 am
- Location: Fort Myers, Florida USA
Post
by AbleMods » Thu Jul 30, 2009 11:54 am
I've seen several cases in AC7 code where (what appears to be) an existing user control is added from the code-behind to a placeholder. Normally these are added as references on the HTML side.
For example:
Code: Select all
ASP.conlib_addtocartlink_ascx add2cart = new ASP.conlib_addtocartlink_ascx();
add2cart.ProductId = product.ProductId;
itemTemplate1.Controls.Add(add2cart);
How is that done? When I expose the ASP class, it's only listing very specific user controls. I'd like to add my own user control to a placeholder using the same technique.
Thoughts?
-
Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Post
by Logan Rhodehamel » Thu Jul 30, 2009 12:35 pm
In the aspx, add a registration entry. Look in the AC examples and look at the top of the file. You will see the user control is registered in the aspx. That makes it available in the code behind.
Be aware this only works in web site project model. Anyone who switches to the web application project model has to do something different.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
-
AbleMods
- Master Yoda
- Posts: 5170
- Joined: Wed Sep 26, 2007 5:47 am
- Location: Fort Myers, Florida USA
Post
by AbleMods » Thu Jul 30, 2009 12:50 pm
Code: Select all
<%--
<conlib>
<summary>Displays a link to add an item to the cart.</summary>
<param name="ProductId">The ID of the product to add to the cart when the link is clicked.</param>
<param name="ShowImage" default="true">Indicates whether an image should be displayed with the link. The image is determined by your theme.</param>
<param name="LinkText" default="">Text to use for the link. You can use the string <b>{0}</b> as a place holder for the product name.</param>
</conlib>
--%>
This what you mean by "registration"?
-
Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Post
by Logan Rhodehamel » Thu Jul 30, 2009 3:22 pm
Code: Select all
<%@ Register Src="~/ConLib/OrderTotalSummary.ascx" TagName="OrderTotalSummary" TagPrefix="uc" %>
Like that.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
-
nickc
- Captain (CAPT)
- Posts: 276
- Joined: Thu Nov 29, 2007 3:48 pm
Post
by nickc » Thu Jul 30, 2009 3:45 pm
Code: Select all
Control control = this.LoadControl(virtualPathOfControlFile); //
myPlaceholder.Controls.Add(control);