Passing Data between 2 ConLib user controls

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Fri May 23, 2008 11:24 am
Location: Puyallup, Wa
Contact:

Passing Data between 2 ConLib user controls

Post by BryanWarmoth » Fri Jun 20, 2008 5:12 pm

I am trying to build an application where a user chooses a product in the middle content area and then the product attributes will show up on the right side bar. I would like to have this done inside an update panel so that there is no postback. Is there anyway to make two different conlib user controls share data together on one page?

Thanks,
Bryan
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Passing Data between 2 ConLib user controls

Post by AbleMods » Sat Jun 21, 2008 5:53 pm

Technically there will still be a postback, it's how the postback code is generated on the client side that changes when you use an update panel.

I pass values between controls using .Net session variables.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Fri May 23, 2008 11:24 am
Location: Puyallup, Wa
Contact:

Re: Passing Data between 2 ConLib user controls

Post by BryanWarmoth » Wed Jun 25, 2008 6:04 pm

Thanks, I got it working using session variables but i am still having some problems with the ajax populating the information section. I can't seem to use an update panel because the 2 controls are in separate parts. My area where you choose the product is in the middle content part and the info should show up in the right sidebar. Any suggestions?
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Passing Data between 2 ConLib user controls

Post by AbleMods » Wed Jun 25, 2008 8:57 pm

BryanWarmoth wrote:Thanks, I got it working using session variables but i am still having some problems with the ajax populating the information section. I can't seem to use an update panel because the 2 controls are in separate parts. My area where you choose the product is in the middle content part and the info should show up in the right sidebar. Any suggestions?
Perhaps this code snippet from my BuyProductDialog user control will lead you down the correct path. The trick is using an Able utility function to search the entire page for a particular control. Then you can direct-cast that reference into a new control and access the properties/methods of the original rendered control. You have no idea how long it took me to get working......8)

Code: Select all

                PlaceHolder phProductImage = (PlaceHolder)PageHelper.RecursiveFindControl(this.Parent, "phProductImage");
                UpdatePanel AJImagePanel = (UpdatePanel)PageHelper.RecursiveFindControl(this.Parent, "ImageAjax");

                string _ImageURL = _OptionChoice.ImageUrl;
                string _ImageAltText = _Product.ImageAltText + " (" + _OptionChoice.Name + ")";
                if (!string.IsNullOrEmpty(_OptionChoice.ImageUrl))
                {
                    phProductImage.Controls.Clear();
                    phProductImage.Controls.Add(new LiteralControl("<img id=\"ProductImage\" src=\"" + Page.ResolveClientUrl(_ImageURL) + "\" border=\"0\" alt=\"" + Server.HtmlEncode(_ImageAltText) + "\" />"));
                    AJImagePanel.Update();
                }
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
BryanWarmoth
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 44
Joined: Fri May 23, 2008 11:24 am
Location: Puyallup, Wa
Contact:

Re: Passing Data between 2 ConLib user controls

Post by BryanWarmoth » Thu Jun 26, 2008 10:33 am

Finally! Thank you so much that worked perfectly!
Bryan Bingham
Warmoth Guitar Products Inc.
bryan@warmoth.com
http://www.warmoth.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Passing Data between 2 ConLib user controls

Post by AbleMods » Thu Jun 26, 2008 12:13 pm

Fantastic 8)
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply