【发布时间】:2011-11-30 14:47:29
【问题描述】:
我在 aspx 页面中有一个用于 HTML 按钮单击事件的 JavaScript 函数,在页面代码隐藏中有一个服务器方法。当用户点击 HTML 按钮时,它将被处理,并且按钮将显示答案。
在使用 AJAX 时如何更新按钮标签?
当我尝试在某处设置更新时,页面不会更新按钮。文本框更新工作正常。从下面的代码可以看出,btnDivide 目前有一个“获取天气”的设置值,但是一旦用户完成处理,我需要更改它。
<script type="text/javascript">
<![CDATA[
// This function creates an asynchronous call to the service
function makeCall(operation){
var n1 = document.getElementById("num1").value;
var n2 = document.getElementById("num2").value;
// If user filled out these fields, call the service
if(n1 && n2){
// Instantiate a service proxy
var proxy = new Service();
// Call correct operation on vf cproxy
switch(operation){
case "gridOne":
proxy.Calculate(AjaxService.Operation.getWeather,n1,n2,
onSuccess, onFail, null);
btnDivide.value = "TestNewValue";
break;
case "gridTwo":
*******
</script>
<style type="text/css">
#result
{
width: 1010px;
}
</style>
</head>
<body>
<h1>Ajax TicTacToe</h1>
<p>Major City: <input type="text" id="num1" onclick="return
num1_onclick()" /></p>
<p>Country: <input type="text" id="num2" onclick="return num2_onclick()"
/></p>
<br />
<input id="btnDivide" type="button" onclick="return makeCall('gridOne');"
value="Get Weather" />
【问题讨论】:
标签: c# asp.net-ajax