gpt4 book ai didi

c# - 更新按钮标签

转载 作者:行者123 更新时间:2023-11-30 17:14:56 26 4
gpt4 key购买 nike

我在 aspx 页面中有一个 HTML 按钮单击事件的 JavaScript 函数,在页面代码隐藏中有一个服务器方法。当用户单击 HTML 按钮时,它将被处理,按钮将显示一个答案。

如何更新按钮标签,因为它使用的是 AJAX?

当我尝试在某处设置更新时,页面没有更新按钮。文本框更新工作正常。从下面的代码中可以看出,btnDivide 目前的设置值为“Get Weather”,但我需要在用户完成处理后更改它。

<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>
&nbsp;
<br />
<input id="btnDivide" type="button" onclick="return makeCall('gridOne');"
value="Get Weather" />

最佳答案

您需要一个事件处理程序来结束请求事件看看这里:http://msdn.microsoft.com/en-us/library/bb383810.aspx

关于c# - 更新按钮标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8327723/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com