Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > unable to use currency selector in a webpart. View modes: 
User avatar
Member
Member
pradipta-netneighbours - 11/19/2012 2:20:11 AM
   
unable to use currency selector in a webpart.
Hello,

I am creating a custom webpart where i am using the currency selector form control to change the default currency of the site. but the selector is not working as no postback is occurring i am selecting any other currency from the selector.

Below is the code which i am using in my webpart acsx file
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CurrencySelector.ascx.cs"
Inherits="CMSWebParts_Custom_CurrencySelector" %>
<%@ Register Src="~/CMSModules/Ecommerce/FormControls/CurrencySelector.ascx" TagName="CurrencySelector"
TagPrefix="cms" %>

<cms:CurrencySelector ID="selectCurrency" runat="server" IsLiveSite="true" DisplayOnlyWithExchangeRate="true"
DoFullPostback="true" IncludeSelected="true" RenderInline="true" />

please guide me as where i am going wrong and how can i make this selectr workout.

Regards,
Azam Khan

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 11/22/2012 9:07:46 AM
   
RE:unable to use currency selector in a webpart.
Hello,


The form controls works inside Kentico forms - e.g. BizForms (On-line forms) or Document type Forms. If you need the control itself, you can create a standard ASP.NET drop-down list and get values from the database (the table called COM_Currency).

Then you need to set up the currency for the actual user like:

//Unless a shopping cart already exists:
If (ECommerceContext.CurrentShoppingcart == null)
{
//Create a new shopping cart with the currency
ShoppingCartInf cart = ShoppingCartInfoProvider.CreateShoppingCartInfo(CMSContext.CurrentSiteID);
cart.ShoppingCartCurrencyID = <your value>;
ECommerceContext.CurrentShoppingcart = cart;
}
Else
{
//Change the currency of existing shopping cart.
ECommerceContext.CurrentShoppingcart.ShoppingCartCurrencyID = <your value>;
}


Best regards,
Helena Grulichova