Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET jQuery
Pls help
 
data:[
jQuery("#chartId").jqchart({url: 'jqchart.ashx'})
]
Posted 11-Jul-13 22:18pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You don't do it through jQuery. It runs through C#. You could fire off your C# code from jquery but the approach you have here is not going to work. Server side code has to run.
  Permalink  
Comments
Member 10064853 at 15-Jul-13 0:38am
   
ok sir thank u pls do help me how to do in client side i have written in server side so that i can check
ryanb31 at 15-Jul-13 7:39am
   
You'll need to post more information about what you are doing. It sounds like you just need to refresh your page.
Member 10064853 at 15-Jul-13 8:25am
   
public partial class Default6 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
 
}
 
[WebMethod]
//public static string GetData(int userid)
public static List GetData()
{
List dataList = new List();
 
MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
string s = string.Empty;
s = "select name,marks from jqchart";
string s1= "select count(name) from jqchart";
int s2 = Convert.ToInt32(s1);
{
MySqlCommand cmd = new MySqlCommand(s, con);
{
con.Open();
cmd.ExecuteNonQuery();
string name;
int marks;
MySqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
//for (int i = 0; i < s2; i++)
{
dataList.Add(new Data(name, marks));

}
 
return dataList.ToList();
}
 
}

//dataList.Add(new Data("Column 1", 100));
//dataList.Add(new Data("Column 2", 75));
//dataList.Add(new Data("Column 3", 50));
//dataList.Add(new Data("Column 4", 25));
//return dataList;

}
public class Data
{
public string ColumnName = "";
public int Value = 0;
 
public Data(string columnName, int value)
{
ColumnName = columnName;
Value = value;
}
}
}
 
ASPX Page
 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', { packages: ['corechart'] });
</script>
<%--simple chart--%>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'Default6.aspx/GetData',
data: {},
success:
function (response) {
drawVisualization(response.d);
}
 
});
})
 
function drawVisualization(dataValues) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Column Name');
data.addColumn('number', 'Column Value');
 
for (var i = 0; i < dataValues.length; i++) {
data.addRow([dataValues[i].ColumnName, dataValues[i].Value]);
}
 
new google.visualization.PieChart(document.getElementById('visualization')).
draw(data, { title: " JQuery Charts Example" });
}

</script>
<body>

<div id="visualization" style="width: 600px; height: 400px;"></div>
 
</body>
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

My aspx page
 
<script src="Scripts/jqchart.js" type="text/javascript"></script>
<%--Changes chart --%>
<script type="text/javascript">
    $(function () {
        var chart;
        $(document).ready(function () {
 
            // Radialize the colors
            Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function (color) {
                return {
                    radialGradient: {
                        cx: 0.5,
                        cy: 0.3,
                        r: 0.7
                    },
                    stops: [
[0, color],
[1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
]
                };
            });
            // Build the chart
            chart = new Highcharts.Chart(
{
    chart:
{
    renderTo: 'container',
    fill: false,
    plotBackgroundColor: null,
    plotBorderWidth: null,
    plotShadow: false
},
    title: {
        text: 'Techsoft Technologies Bangalore, 2013'
    },
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage}%</b>',
        percentageDecimals: 1
    },
    highlighter: {
        show: true,
        sizeAdjust: 7.5
    },
    plotOptions: {
        pie:
{
    allowPointSelect: true,
    cursor: 'pointer',
    dataLabels:
{
    enabled: true,
    color: '#000000',
    connectorColor: '#000000',
    formatter: function () {
        return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
    }
}
}
    },
    series: [
{
    type: 'pie',
    name: 'Strength',
 
    data: [
       ['Firefox', 45.0],
    ['IE', 26.8],
    {
        name: 'Chrome',
        y: 12.8,
            ////sliced: true,
        selected: true
    },
    ['Safari', 8.5],
    ['Opera', 6.2],
    ['Others', 0.7]
 

]
}
]
});
        });
    });
</script>
<body>
 <script src="Scripts/high.js" type="text/javascript"></script>
 <script src="Scripts/high1.js" type="text/javascript"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
</div>
</body>
 

My CS page
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using MySql.Data.MySqlClient;
using System.Web.Script.Serialization;
using System.Web.UI.DataVisualization;
using System.Data;
 
public partial class Default5 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    [WebMethod]
    //public static string GetData(int userid)
    public static List<Data> GetData()
    {
 
        List<Data> dataList = new List<Data>();
 
        MySqlConnection con = new MySqlConnection("Server=localhost;Port=3306;Database=projecttt;UID=root;Pwd=techsoft;pooling=false");
        string s = string.Empty;
        s = "select name,marks from jqchart";
        //string s1 = "select count(name) from jqchart";
        //int s2 = Convert.ToInt32(s1);
        {
            MySqlCommand cmd = new MySqlCommand(s, con);
            {
                con.Open();
                cmd.ExecuteNonQuery();
                //string name;
                //int marks;
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                //for (int i = 0; i < s2; i++)
                {
                    string a = dr[0].ToString();
                    string b = dr[1].ToString();
                    dataList.Add(new Data(a, int.Parse(b)));
 
                }
 
                return dataList;
 
            }
 
        }
 
        //dataList.Add(new Data("Column 1", 100));
        //dataList.Add(new Data("Column 2", 75));
        //dataList.Add(new Data("Column 3", 50));
        //dataList.Add(new Data("Column 4", 25));
        //return dataList;   
    }
    public class Data
    {
        public string ColumnName = "";
        public int Value = 0;
 
        public Data(string columnName, int value)
        {
            ColumnName = columnName;
            Value = value;
        }
    }
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 31 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100