在asp.net中调用客户端的服务器端方法

时间:2011-09-06 13:14:00

标签: c# asp.net

这是我必须在我的ASP.NET页面中使用的JavaScript,如何更改它以便它在ASP.NET中工作?

<script type="text/javascript">
        window.onload = function ()
        {
            /**
            * These are not angles - these are values. The appropriate angles are calculated
            */

            <% Message message = (Message)request.getSession().getAttribute("message");

            out.print("var pie1 = new RGraph.Pie('pie1',"+Statistics.messagePercentStats(message.getMessageID()) + ")"); %>

             // Create the pie object
            pie1.Set('chart.key', ['Read', 'Received', 'Not Received']);
            pie1.Set('chart.colors',['#86cf21', '#eaa600', '#e01600']);
            pie1.Set('chart.title', "Message Status");
            pie1.Set('chart.align', 'left');
            pie1.Set('chart.shadow', true);
            pie1.Set('chart.radius', 80);
            pie1.Set('chart.labels.sticks', false);
            pie1.Set('chart.highlight.style', '2d'); // Defaults to 3d anyway; can be 2d or 3d


            if (!RGraph.isIE8()) 
            {
                pie1.Set('chart.zoom.hdir', 'center');
                pie1.Set('chart.zoom.vdir', 'up');
                pie1.Set('chart.labels.sticks', false);
                pie1.Set('chart.labels.sticks.color', '#aaa');
            }
            pie1.Draw();
        }
    </script>

我应该如何更改此行以从我的名为messagePercentStats的类中获取值?

RGraph.Pie('pie1',"+Statistics.messagePercentStats(message.getMessageID()) + ")"); %>

1 个答案:

答案 0 :(得分:0)

我认为你可能会尝试这样做,假设RGraph.Pie是客户端的。

RGraph.Pie('pie1',
           '<%= Statistics.messagePercentStats(
                     ((Message)request.Session["message"]).getMessageID() %>');