I have tried to add a table with limited success, the label appears in the first column but the control is outside, any help appreciated as I would like to have the label and the control left justified, and both in the table
I have added a few lines of code for a table but if you look at the link you will see the problem
http://www.abreena.co.uk/products/103-bride-groom-engraved-champagne-bottle-with-photograph.aspx
Steve
//------------------------------------------------------------------------------
// The contents of this file are subject to the nopCommerce Public License Version 1.0 ("License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at https://www.nopcommerce.com/License.aspx.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
// See the License for the specific language governing rights and limitations under the License.
//
// The Original Code is nopCommerce.
// The Initial Developer of the Original Code is NopSolutions.
// All Rights Reserved.
//
// Contributor(s): _______.
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings;
using NopSolutions.NopCommerce.BusinessLogic.Directory;
using NopSolutions.NopCommerce.BusinessLogic.Localization;
using NopSolutions.NopCommerce.BusinessLogic.Products;
using NopSolutions.NopCommerce.BusinessLogic.Products.Attributes;
using NopSolutions.NopCommerce.BusinessLogic.Tax;
using NopSolutions.NopCommerce.Common.Utils;
using System.Globalization;
using NopSolutions.NopCommerce.Controls;
namespace NopSolutions.NopCommerce.Web.Modules
{
public partial class ProductAttributesControl : BaseNopUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
CreateAttributeControls();
}
public void CreateAttributeControls()
{
var productVariant = ProductManager.GetProductVariantById(this.ProductVariantId);
if (productVariant != null)
{
this.phAttributes.Controls.Clear();
var productVariantAttributes = productVariant.ProductVariantAttributes;
if (productVariantAttributes.Count > 0)
{
StringBuilder adjustmentTableScripts = new StringBuilder();
StringBuilder attributeScripts = new StringBuilder();
this.Visible = true;
foreach (var attribute in productVariantAttributes)
{
var divAttribute = new Panel();
var attributeTitle = new Label();
// CODE-CHANGE BY SM ADDED DIV ADDED SO EACH ATTRIBUTE ALIGNS ON LEFT
// *********************************************************
attributeTitle.Text = "<table width='100%' border='1'>";
attributeTitle.Text += "<tr >";
attributeTitle.Text += "<td width='33%'>";
// *********************************************************
if (attribute.IsRequired)
// attributeTitle.Text = "<span>*</span> ";
attributeTitle.Text += "<span style='color:red'><br/>*</span> "; // CODE-CHANGE BY SM * IS NOW COLOURED RED & <br /> ADDED
else
attributeTitle.Text += "<span><br/> </span>"; // CODE-CHANGE BY SM * IS NOW COLOURED RED & <br /> ADDED
//text prompt / title
string textPrompt = string.Empty;
if (!string.IsNullOrEmpty(attribute.TextPrompt))
textPrompt = attribute.TextPrompt;
else
textPrompt = attribute.ProductAttribute.LocalizedName;
attributeTitle.Text += Server.HtmlEncode(textPrompt);
attributeTitle.Style.Add("font-weight", "bold");
//description
if (!string.IsNullOrEmpty(attribute.ProductAttribute.LocalizedDescription))
attributeTitle.Text += string.Format("<span>{0}</span>", Server.HtmlEncode(attribute.ProductAttribute.LocalizedDescription));
bool addBreak = true;
switch (attribute.AttributeControlType)
{
case AttributeControlTypeEnum.TextBox:
case AttributeControlTypeEnum.DropdownList: // CODE-CHANGE BY SM ~ NOT NEEDED
case AttributeControlTypeEnum.Datepicker: // CODE-CHANGE BY SM ~ NOT NEEDED
{
//addBreak = false; // CODE-CHANGE BY SM ~ ADDS NEW LINE FOR ALL CONTROLS
}
break;
default:
break;
}
if (addBreak)
{
attributeTitle.Text += "<br />";
}
else
{
attributeTitle.Text += " ";
}
divAttribute.Controls.Add(attributeTitle);
phAttributes.Controls.Add(divAttribute);
attributeTitle.Text += "</td>"; // CODE-CHANGE BY SM ADDED DIV ADDED SO EACH ATTRIBUTE ALIGNS ON LEFT
attributeTitle.Text += "<td>"; // CODE-CHANGE BY SM ADDED DIV ADDED SO EACH ATTRIBUTE ALIGNS ON LEFT
string controlId = string.Format("{0}_{1}", attribute.ProductAttribute.ProductAttributeId, attribute.ProductVariantAttributeId);
switch (attribute.AttributeControlType)
{
case AttributeControlTypeEnum.DropdownList:
{
var ddlAttributes = new DropDownList();
ddlAttributes.ID = controlId;
divAttribute.Controls.Add(ddlAttributes);
ddlAttributes.Items.Clear();
if (!attribute.IsRequired)
{
ddlAttributes.Items.Add(new ListItem("---", "0"));
}
var pvaValues = attribute.ProductVariantAttributeValues;
adjustmentTableScripts.AppendFormat("{0}['{1}'] = new Array(", AdjustmentTableName, ddlAttributes.ClientID);
attributeScripts.AppendFormat("$('#{0}').change(function(){{{1}();}});\n", ddlAttributes.ClientID, AdjustmentFuncName);
bool preSelectedSet = false;
foreach (var pvaValue in pvaValues)
{
string pvaValueName = pvaValue.LocalizedName;
if (!this.HidePrices &&
(!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
(NopContext.Current.User != null &&
!NopContext.Current.User.IsGuest)))
{
decimal taxRate = decimal.Zero;
decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate);
decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
if (priceAdjustmentBase > decimal.Zero)
{
pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false));
}
adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0},", (float)priceAdjustment);
}
var pvaValueItem = new ListItem(pvaValueName, pvaValue.ProductVariantAttributeValueId.ToString());
if (!preSelectedSet && pvaValue.IsPreSelected)
{
pvaValueItem.Selected = pvaValue.IsPreSelected;
preSelectedSet = true;
}
ddlAttributes.Items.Add(pvaValueItem);
}
adjustmentTableScripts.Length -= 1;
adjustmentTableScripts.Append(");\n");
}
break;
case AttributeControlTypeEnum.RadioList:
{
var rblAttributes = new RadioButtonList();
rblAttributes.ID = controlId;
divAttribute.Controls.Add(rblAttributes);
rblAttributes.Items.Clear();
var pvaValues = attribute.ProductVariantAttributeValues;
bool preSelectedSet = false;
foreach (var pvaValue in pvaValues)
{
string pvaValueName = pvaValue.LocalizedName;
if (!this.HidePrices &&
(!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
(NopContext.Current.User != null &&
!NopContext.Current.User.IsGuest)))
{
decimal taxRate = decimal.Zero;
decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate);
decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
if (priceAdjustmentBase > decimal.Zero)
{
pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false));
}
adjustmentTableScripts.AppendFormat(CultureInfo.InvariantCulture, "{0}['{1}_{2}'] = {3};\n", AdjustmentTableName, rblAttributes.ClientID, rblAttributes.Items.Count, (float)priceAdjustment);
attributeScripts.AppendFormat("$('#{0}_{1}').click(function(){{{2}();}});\n", rblAttributes.ClientID, rblAttributes.Items.Count, AdjustmentFuncName);
}
var pvaValueItem = new ListItem(Server.HtmlEncode(pvaValueName), pvaValue.ProductVariantAttributeValueId.ToString());
if (!preSelectedSet && pvaValue.IsPreSelected)
{
pvaValueItem.Selected = pvaValue.IsPreSelected;
preSelectedSet = true;
}
rblAttributes.Items.Add(pvaValueItem);
}
}
break;
case AttributeControlTypeEnum.Checkboxes:
{
var cblAttributes = new CheckBoxList();
cblAttributes.ID = controlId;
divAttribute.Controls.Add(cblAttributes);
cblAttributes.Items.Clear();
var pvaValues = attribute.ProductVariantAttributeValues;
foreach (var pvaValue in pvaValues)
{
string pvaValueName = pvaValue.LocalizedName;
if (!this.HidePrices &&
(!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
(NopContext.Current.User != null &&
!NopContext.Current.User.IsGuest)))
{
decimal taxRate = decimal.Zero;
decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment, out taxRate);
decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
if (priceAdjustmentBase > decimal.Zero)
pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceA