Highchar dissapear with postback!!

Jun 25, 2014 at 5:57 PM
I really want to know what is happening with my code. it throws this message : "Error en tiempo de ejecución de Microsoft JScript: Se esperaba un objeto".

And this is the code that shows with the error message:

var chartctl00_PlaceHolder_separador19separador739separador58_C_ctl00_hcbardistribucion;

$(document).ready(function() {
    chartctl00_PlaceHolder_separador19separador739separador58_C_ctl00_hcbardistribucion = new Highcharts.Chart({
    chart: {"renderTo":"ctl00_PlaceHolder_separador19separador739separador58_C_ctl00_hcbardistribucion","defaultSeriesType":"bar","plotBorderColor":"#FFFFFF"},
    labels: {},

    credits: { enabled: false },
    plotOptions: { series: {} },
    title: {"text":""},

    legend: {"enabled":true},
    exporting: {"enabled":false},
    xAxis: [{"categories":["Aktien - Deutschland","Aktien - USA","Aktien - Europa","Alternative Investments - Edelmetalle","Geldmarkt - Europa"],"labels":{"enabled":true,"style":{"fontSize":"9px","fontFamily":"Verdana"},"ownformat":false},"title":{"text":""}}],
    yAxis: [{"gridLineWidth":0,"labels":{"enabled":false,"style":{"fontSize":"9px","fontFamily":"Verdana"},"ownformat":false},"min":0.0,"title":{"text":""}}],
    tooltip: {"ownformat":false,"formatter":function(event){ var tmp = '<b>'+ this.series.name + ((typeof(this.point.name) != 'undefined') ? '->'  +this.point.name : '' )+ ' </b><br/>'+ this.x +': '+ this.y; if(typeof(tmp) == 'function'){return tmp(this);}else{ return tmp;} }} ,
    series: [{"type":"bar","data":[{name: 'Aktien - Deutschland' , color: '#55AAEF', y: 0.430303676221025},{name: 'Aktien - USA' , color: '#55AAEF', y: 0.228118740374232},{name: 'Aktien - Europa' , color: '#55AAEF', y: 0.256106210967529},{name: 'Alternative Investments - Edelmetalle' , color: '#55AAEF', y: 0.0636334147801632},{name: 'Geldmarkt - Europa' , color: '#55AAEF', y: 0.0218379576570506}],"showInLegend":false}]
    });          
});

this is my code in ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DistribucionActivos.ascx.cs"
    Inherits="Controls_Cliente_DistribucionActivos" EnableViewState="true" %>
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr>
    <td>

            <asp:Label ID="lblSinDatos" runat="server" Visible="false" Text="<%$ Resources:Common, k001594 %>"/>
            <highchart:BarChart ID="hcbardistribucion" Width="440" Height="50" runat="server"/>                                        

    </td>
</tr>
</table>
And this is my .cs:
using Highchart.Core;
using Highchart.UI;
using Highchart.Core.PlotOptions;
using Highchart.Core.Appearance;
using Highchart.Core.HtmlLabel;
using Highchart.Core.Events;
using Highchart.Core.Data.Chart;

///<summary>
///</summary>
public partial class Controls_Cliente_DistribucionActivos : BaseUserControl
{
    Cartera _carteraActual = new Cartera();

    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        TablaPesos();
    }

    private void TablaPesos()
    {     
        Seguridad.FormsPrincipal principal = (Seguridad.FormsPrincipal)HttpContext.Current.User;
        string tieneFuncion22 = string.Empty;

        if (!principal.IsActionEnabled("verElemtAjeno"))
        { tieneFuncion22 = "0"; }
        else
        { tieneFuncion22 = "1"; }

        DatosSesion dataUserTMP = (DatosSesion)Session["SesionWMP"];

        /*Se realiza una comprobación para ver si el cliente está siendo consultado a través del buscador de rut.*/
        /*En tal caso, activar también la función 22 y pasar la jerarquia del centro cúspide.*/
        string jerarquia = dataUserTMP.DatosUsuario.Jerarquia.ToString();
        if (Session["rut"] != null)
        {
            if (Session["rut"].ToString() == Session["ClienteID"].ToString())
            {
                tieneFuncion22 = "1";
                jerarquia = dataUserTMP.DatosUsuario.JerarquiaCuspide.ToString();
            }
        }
        ClienteCRM datosCliente = null;
        List<BusinessObjects.WmPlus.Categoria> ListaCat = new List<Categoria>();
        int carteraId = Session["CarteraID"] !=null ? Convert.ToInt32(Session["CarteraID"].ToString()) : 0;
        if (!carteraId.Equals(0))
        {
            datosCliente = BLClientDetails.ListarDatosIniciales(Convert.ToInt32(Session["ClienteID"].ToString()), _SesionWMP.DatosUsuario.AreaID, carteraId, getShortLanguage());

            _carteraActual = (Session["CarteraWMP"] != null) ? (Cartera)Session["CarteraWMP"] : BLGestorCarteras.RetornaCartera(datosCliente.CodigoCartera, dataUserTMP.DatosUsuario.AreaID);

             ListaCat = BusinessDisposer.BL.BLGestorCarteras.ListaCategorias(datosCliente.CodigoCartera, _carteraActual.FechaInicio, _carteraActual.FechaSaldo, "", dataUserTMP.DatosUsuario.AreaID, "");
        }

        List<DistribucionCategoria> Lista = new List<DistribucionCategoria>();

        if (System.Configuration.ConfigurationManager.AppSettings["EsComdirect"].ToString() != "True")
        {
            Lista = BLCliente.ListarProductosPorCategoria(dataUserTMP.DatosUsuario.AreaID, Convert.ToInt32(Session["ClienteID"].ToString()), dataUserTMP.DatosAreaNegocio.DivisaReferencia, DateTime.Now.AddDays(-1), dataUserTMP.DatosUsuario.Identificador, jerarquia, dataUserTMP.DatosUsuario.Rol, tieneFuncion22);
        }
        else 
        {
            foreach (BusinessObjects.WmPlus.Categoria x in ListaCat)
            {
                Lista.Add(new DistribucionCategoria() { Categoria = x.Nombre, Peso = x.PesoFinal });
            }        
        }

        hcbardistribucion.PlotOptions = null;
        hcbardistribucion.Series.Clear();
        hcbardistribucion.YAxis.Clear();
        hcbardistribucion.XAxis.Clear();
        hcbardistribucion.Height = 0;

        if (Lista.Count > 0)
            hcbardistribucion.Visible = true;
        else
        {
            lblSinDatos.Visible = true;
            hcbardistribucion.Visible = false;
            return;
        }

        //INICIO Pinta los pesos en Highchart
        //Setea propiedades basicas del highchart para las barras

        hcbardistribucion.Appearance.renderTo = "container";
        hcbardistribucion.Appearance.defaultSeriesType = "bar";
        hcbardistribucion.Appearance.plotBorderColor = "#FFFFFF";


        //Crea las axis
        object[] categorias = new object[Lista.Count];
        List<DataBar> ba = new List<DataBar>();
        SerieCollection series = new SerieCollection();

        //Completa los datos de las categorias para que sean configurables en el eje Y
        //Completa las series 

        ba = new List<DataBar>();

        for (int i = 0; i < Lista.Count; i++)
        {
            categorias[i] = Lista[i].Categoria;
            ba.Add(new DataBar() { color = "#55AAEF", name = Lista[i].Categoria, y = Lista[i].Peso });
        }

        //Asigna los valores a la serie
        series.Add(new Serie() { type = RenderType.bar, databar = ba, showInLegend = false });

        hcbardistribucion.XAxis.Add(new XAxisItem() { categories = categorias, labels = new Labels() { style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "9px" } } });
        hcbardistribucion.YAxis.Add(new YAxisItem() { min = 0,  gridLineWidth = 0, labels = new Labels() { enabled = false, style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "9px" } } });


        //hcbardistribucion.XAxis.Add(new XAxisItem() { categories = categorias, gridLineWidth = 0, lineWidth = 0, minorGridLineWidth = 0, tickColor = "#FFFFFF", labels = new Labels() { style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "9px" } } });
        //hcbardistribucion.YAxis.Add(new YAxisItem() { min = 0, max = 2, title = new Title(""), gridLineWidth = 0, lineWidth = 0, minorGridLineWidth = 0, labels = new Labels() { enabled = false, style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "9px" } } });

        //Calcula el tamaño de alto del cuadro
        hcbardistribucion.Height = new Unit(hcbardistribucion.Height.Value + ((ba.Count == 1 ? 3 : ba.Count) - 1) * 35);
        //hcbardistribucion.Width = new Unit(440);

         //Formateado del texto---
    hcbardistribucion.Tooltip = new ToolTip()
    {
        style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "8px" },
        formatter = "this.x + ' ' + Highcharts.numberFormat(this.y*100, 2, '" + dataUserTMP.DatosAreaNegocio.SeparadorDecimal + "','" + dataUserTMP.DatosAreaNegocio.SeparadorGrupal + "') +' %'"
    };

    ////Configuracion del plano
    ////color = "#55AAEF"
    hcbardistribucion.PlotOptions = new PlotOptionsBar()
    {

        borderColor = "#FFFFFF",
        dataLabels = new DataLabels() { enabled = true, formatter = "Highcharts.numberFormat(this.y*100, 0, '" + dataUserTMP.DatosAreaNegocio.SeparadorDecimal + "','" + dataUserTMP.DatosAreaNegocio.SeparadorGrupal + "') +' %'", color = "#999999", style = new Highchart.Core.Appearance.CSSObject { fontFamily = "Verdana", fontSize = "9px" } },
        shadow = false
    };

     hcbardistribucion.DataSource = series;
    hcbardistribucion.DataBind();
}
}
Thanks a lot for your help!