HTMLEditor

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 年 前
I'm trying to add dynamic content to the HTMLEditor in the ProductAdd page.  I've tried everything.  Anybody have some advice?
14 年 前
sorry for asking the obvious, but did you switch the editor  to html view first?

post an example of what you are trying to add.
- H
14 年 前
I did try and turn the default mode of the HTMLEditor to HTML before adding dynamic content and it still wouldn't work.  Here is the code:

<%
    if (Page.IsPostBack)
    {
        tdAWSImage.InnerHtml = "";
        trAmazonImage.Visible = false;

        if (radEnableAWS.Checked == true && !String.IsNullOrEmpty(txtAWSKeyword.Value))
        {
            string keywords = txtAWSKeyword.Value;
            SignedRequestHelper helper = new SignedRequestHelper(WebConfigurationManager.AppSettings["AWS_ACCESS_KEY"].ToString(), WebConfigurationManager.AppSettings["AWS_SECRET_KEY"].ToString(), WebConfigurationManager.AppSettings["DESTINATION"].ToString());

            String requestString = "Service=AWSECommerceService"
                + "&Version=2009-11-01"
                + "&Operation=ItemSearch"
                + "&SearchIndex=All"
                + "&ResponseGroup=Medium"
                + "&Keywords=" + keywords;

            string url = helper.Sign(requestString);
            try
            {
                WebRequest request = HttpWebRequest.Create(url);
                WebResponse response = request.GetResponse();
                XmlDocument doc = new XmlDocument();
                doc.Load(response.GetResponseStream());

                if (doc.HasChildNodes)
                {
                    XmlNodeList items = doc.GetElementsByTagName("Item");

                    //create data table for amazon products
                    string tableDisplay = "<table>";
                    for (int i = 0; i < items.Count; i++)
                    {
                        if (!string.IsNullOrEmpty(items[i]["ImageSets"]["ImageSet"]["LargeImage"]["URL"].InnerText))
                        {
                            txtName.Text = items[i]["ItemAttributes"]["Title"].InnerText;
                            txtShortDescription.Text = items[i]["ItemAttributes"]["Title"].InnerText + " (" + items[i]["ItemAttributes"]["Binding"].InnerText + ")";
                            txtFullDescription.Content = items[i]["EditorialReviews"]["EditorialReview"]["Content"].InnerText;
                            lblPriceAWS.Text = items[i]["OfferSummary"]["LowestUsedPrice"]["FormattedPrice"].InnerText + " - " + items[i]["OfferSummary"]["LowestNewPrice"]["FormattedPrice"].InnerText;

                            //get weight
                            if (!String.IsNullOrEmpty(items[i]["ItemAttributes"]["PackageDimensions"]["Weight"].InnerText))
                            {
                                txtWeight.Value = Convert.ToDecimal(items[i]["ItemAttributes"]["PackageDimensions"]["Weight"].InnerText) / 100;
                                txtLength.Value = Convert.ToDecimal(items[i]["ItemAttributes"]["PackageDimensions"]["Length"].InnerText) / 100;
                                txtHeight.Value = Convert.ToDecimal(items[i]["ItemAttributes"]["PackageDimensions"]["Height"].InnerText) / 100;
                                txtWidth.Value = Convert.ToDecimal(items[i]["ItemAttributes"]["PackageDimensions"]["Width"].InnerText) / 100;
                            }

                            //set image
                            tableDisplay += "<tr>";
                            trAmazonImage.Visible = true;
                            tableDisplay += "<td><img src='" + items[i]["ImageSets"]["ImageSet"]["LargeImage"]["URL"].InnerText + "'/></td>";
                            tableDisplay += "</tr>";
                            tableDisplay += "</table>";
                            tdAWSImage.InnerHtml = tableDisplay;

                            tbDescriptionAWS.Text = items[i]["EditorialReviews"]["EditorialReview"]["Content"].InnerText;
                            rowDescription.Visible = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message + "<br />" + ex.Source + "<br />" + ex.Data + "<br />" + ex.StackTrace + "<br />" + ex.InnerException);
            }
        }
    }
%>

The code that I tried getting to work is marked in bold.  I tried multiple different ways and I couldn't get the text to show up in the HTMLEditor.

BTW, I found javascript code to disable the Validators on the ProductAdd.aspx page so I could run this script without having to save the product.  I added some content to the ProductAddInfo.ascx page and when an Administrator enables the content by clicking on a radio button, here is the javascript that runs to disable the validators.  Also, the Administrator can disable the the added content and re-enable the validators by selecting a different radio button:

    function AWS(rad) {
        if (rad.value == "true") {
            document.getElementById('rowAWS').style.display = 'table-row';
            for (i = 0; i < Page_Validators.length; i++) {
                ValidatorEnable(Page_Validators[i], false);
            }
        }
        else {
            document.getElementById('rowAWS').style.display = 'none';
            for (i = 0; i < Page_Validators.length; i++) {
                ValidatorEnable(Page_Validators[i], true);
            }
        }
    }

The validators are automatically created on the page in a JavaScript array called Page_Validators.  Accessing them and turning them off is as simple as the JavaScript code above.
14 年 前
deccks wrote:
I'm trying to add dynamic content to the HTMLEditor in the ProductAdd page.  I've tried everything.  Anybody have some advice?

if i follow you, you want code to run  on the product page of a particular product?

how about creating a new product template for this product and hard coding the above to that particular template - you could then use that template for any product you choose
14 年 前
I see what you're saying.  I'll do that.  Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.