我有一个我想从 javascript 调用的 vb.net 函数,它们都在 .ascx 中。在这段代码中,我使用 jquery 来弹出一个对话框,然后单击对话框上的按钮(btnok),我想调用一个函数 loadgraph(),它是一个 vb.net 函数。
<link href="css/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="javascript/jquery-1.8.3.js" type="text/javascript"></script>
<script src="javascript/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<link href="css/demos.css" rel="stylesheet" type="text/css" />
<script src="javascript/jquery-ui.js" type="text/javascript"></script>
<script>
// increase the default animation speed to exaggerate the effect
$.fx.speeds._default = 1000;
$(function() {
$( "#element_to_pop_up" ).dialog({
autoOpen: false,
show: "blind",
hide: "explode"
});
$( "#button" ).click(function() {
$( "#element_to_pop_up" ).dialog( "open" );
return false;
});
$( "#btnok" ).click(function(){
$( "#element_to_pop_up" ).dialog( "close" );
$.ajax({
type: "POST",
url: "Schart.ascx/loadgraph",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do something interesting here.
alert("called")
}
});
return false;
});
});
</script>