TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anand MR
NA
39
19.9k
To load script,css links to aspx head section dynamicaly(c#
Nov 19 2014 6:54 AM
Hi,
I have created asmx(c#) webservice for morris chart.Now while invoking my web service from my asp.net application, i have manually need to include the following links in my page head section that are supported for morris charts.
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
<script src="morrisfile/morris.js"></script>
<link href="morrisfile/morris.css" rel="stylesheet" />
It is possible to load this link to my aspx page head section while invoking the web service.I dont want to add it mannually.Everything need to getting from the webservice itself.
[Webmethod]
public string googleAPIPieChart(DataTable dt, String chartTitle = null, string chartHeight = null, string chartWidth = null)
{
chartTitle = chartTitle ?? "Sample Pie Chart";
chartHeight = chartHeight ?? "250";
chartWidth = chartWidth ?? "250";
StringBuilder sb = new StringBuilder();
try
{
string sJsonData = Charts.ConvertDataTableToString(dt);
sb.Append("<div id=" + "\"" + "Pie" + "\"" + "></div>");
sb.Append(Environment.NewLine);
sb.Append(Environment.NewLine);
sb.Append("<script type=" + "\"" + "text/javascript" + "\"" + ">");
sb.Append(Environment.NewLine);
sb.Append("google.load(" + "\"visualization\"" + "," + "\"1\"" + "," + " " + "{" + " packages: " + "[" + "\"corechart\"" + "]});");
sb.Append(Environment.NewLine);
sb.Append("google.setOnLoadCallback(" + "drawChart" + ");");
sb.Append(Environment.NewLine);
sb.Append("function" + " " + "drawChart() {");
sb.Append(Environment.NewLine);
sb.Append("var data = google.visualization.arrayToDataTable([");
sb.Append(Environment.NewLine);
sb.Append(sJsonData);
sb.Append("]);");
sb.Append(Environment.NewLine);
sb.Append("var options = {");
sb.Append(Environment.NewLine);
sb.Append("title: " + "\'" + chartTitle + "\'" + ",");
sb.Append("legend: " + "\'" + "none" + "\'" + ",");
sb.Append(Environment.NewLine);
sb.Append("width: " + chartWidth + ",");
sb.Append(Environment.NewLine);
sb.Append("height: " + chartHeight);
sb.Append(Environment.NewLine);
sb.Append("};");
sb.Append(Environment.NewLine);
sb.Append("var chart = new google.visualization.PieChart(document.getElementById(" + "\'" + "Pie" + "\'" + "));");
sb.Append(Environment.NewLine);
sb.Append("chart.draw(data, options);");
sb.Append(Environment.NewLine);
sb.Append("}");
sb.Append(Environment.NewLine);
sb.Append("</script>");
}
catch (Exception ex)
{
Charts.ChartlogFile(ex.Message.ToString() + "\n");
}
return sb.ToString();
}
My aspx Page
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.2/raphael-min.js"></script>
<script src="morrisfile/morris.js"></script>
<link href="morrisfile/morris.css" rel="stylesheet" />
<script src="morrisfile/morris.min.js"></script>
<link href="morrisfile/morris.core.less" rel="stylesheet"></link>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/prettify/r224/prettify.min.css"/>
<link href="morrisfile/example.css" rel="stylesheet" />
<script src="morrisfile/example.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="chartData" style="width:400px;" runat="server"></div>
<table>
Please advice me to get this functionality.
Reply
Answers (
1
)
Soap server
Entry point in the web serice