我以前使用highcharts從數據庫中獲取數據,但是因爲它位於更新面板中,所以沒有顯示數據。使用這種無線電使用單選按鈕,highcharts從服務器獲取數據
<input class="test" name="ga" type="radio" value="a"> name</input>
<input class="test" name="ga" type="radio" value="b"> last</input>
<input class="test" name="ga" type="radio" value="c"> first</input>
,數據是工作,因爲我稱爲從vb.net我通過使隱藏字段,並得到數據集到一個數組這樣做的背面代碼的JavaScript,從那裏我使用的Json然後將其稱爲隱藏值並將其顯示在圖表上。但是現在我需要使用單選按鈕來實現聊天:下面的代碼是我的單選按鈕,同樣的概念...
<asp:RadioButtonList RepeatDirection="Horizontal" CssClass="radioList test"
ID="RadioButtonList1" AutoPostBack="true" runat="server"
RepeatLayout="Flow" name="ga" type="radio">
<asp:ListItem Selected="True" Value="a">name</asp:ListItem>
<asp:ListItem Value="a">first</asp:ListItem>
<asp:ListItem Value="a">last</asp:ListItem>
</asp:RadioButtonList>
當我使用此代碼,數據確實不知道,當我刷新它不從服務器獲取數據。我的JavaScript代碼:
$(function() {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
}
});
$(".test").change(function() {
var value = this.getAttribute("value");
while (chart.series.length > 0) {
chart.series[0].remove(true);
}
if (value == 'a') {
chart.xAxis[0].update({categories: ['Jan', 'Feb', 'Mar']});
chart.yAxis[0].setTitle({ text: "name" });
chart.addSeries({
name: 'Rainfall11',
type: 'column',
data:array(comes from vb.net)
});
chart.addSeries({
name: 'Rainfall2',
type: 'column',
data: array2 (comes from vb.net)
});
chart.addSeries({
name: 'Rainfall3',
type: 'column',
color: '#FFA500',
data: array3 (comes from vb.net)
});
} else if (value == 'b') {
chart.yAxis[0].setTitle({ text: "first" });
} else if (value == 'c') {
chart.addSeries({
name: 'Rainfall5',
type: 'column',
data:array5
});
chart.addSeries({
name: 'Rainfall6',
type: 'column',
data:array6
});
} else {
alert("Error!");
}
});});
的問題是,我無法從服務器獲取數據,因爲當我刷新頁面它不加載它,它只調用它的JavaScript ..我有谷歌這一點,覺得它與更新面板,使用重繪方法或使用RegisterClientScriptBlock有關。
這是我從MSDN了,爲的RegisterClientScriptBlock:
Dim script As String
script = _
"function ToggleItem(id)" & _
" {" & _
" var elem = $get('div'+id);" & _
" if (elem)" & _
" {" & _
" if (elem.style.display != 'block') " & _
" {" & _
" elem.style.display = 'block';" & _
" elem.style.visibility = 'visible';" & _
" } " & _
" else" & _
" {" & _
" elem.style.display = 'none';" & _
" elem.style.visibility = 'hidden';" & _
" }" & _
" }" & _
" }"
ScriptManager.RegisterClientScriptBlock(_
Me, _
GetType(Page), _
"ToggleScript", _
script, _
True)
所以我的javascript代碼往裏走呢?
我被告知,使用vb中的RegisterClientScriptBlock方法將工作。然後使用highchrts重繪,但改變了javascript的功能,但問題在於它將被排除 – al123
我從來沒有使用過AJAX調用,但我被告知它可以與RegisterClientScriptBlock – al123
工作我從來沒有使用RegisterClientScriptBlock,所以我不能幫你。如果發現[this](http://encosia.com/jquery-for-the-asp-net-developer/)系列帖子在過去很有用(我已轉移到ASP.NET MVC)。 – ssarabando