如何将变量从客户端传递到服务器端以设置 webchartcontol 宽度

How to pass variable from client side to the server side to set the webchartcontol width

我的问题是 devexpress 库的 webchartcontrol 只接受以 px 为单位的宽度而不是相对宽度,我想将宽度记录设置到它的父级 div。

我尝试了很多东西,但由于缺乏编码,我是 asp.net 的初学者。我不知道将 div 的宽度传递到服务器端然后在页面加载时设置图表控件宽度的正确方法,我尝试设置隐藏字段值并从 JavaScript 调用但是没用

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">




    <div id="demo">

        <input id="Hidden1" type="hidden" value="500" runat="server"/>

        <script type="text/javascript">

           document.getElementById("Hidden1").value = 1000;
        </script>





        <dx:WebChartControl ID="Chart" runat="server" OnCustomCallback="Chart_CustomCallback" CrosshairEnabled="True" Height="200px" Width="300px">


        </dx:WebChartControl>




    </div>

</asp:Content>


 protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                  Load_Live_Trend(Chart);
                Chart.Width = new Unit(Convert.ToInt32(Hidden1));

            }



        }

从 v18.2 开始,WebChartControl 支持客户端SetChartSize method that sends a callback and render the chart with a new size (see the ASPxClientWebChartControl API). See also: https://github.com/DevExpress-Examples/how-to-resize-a-chart-according-to-the-actual-size-of-a-web-browsers-window-e252