且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

防止页面回发

更新时间:2023-12-02 10:44:04

您可以使用 Javascript 进行同样的操作.

如果使用HTML Input控件显示按钮,请使用onclick event.
如果使用的是ASP按钮,则使用按钮的OnClientClick 属性.

使用这些属性调用Javascript方法,然后在JS函数中将文本更改为所需的值.您是否愿意进行操纵.

如果您对 jQuery 有所了解,也可以使用 jQuery .
You can use Javascript to do the same.

If you are using HTML Input control for showing buttons, then use onclick event.
If you are using ASP button, then use OnClientClick property of the button.

Call a Javascript method using those properties, and in the JS function, change the text to desired value. Do you manipulations as you want to.

You can also use jQuery if you have knowledge on the same.


编写javascript函数

Write a javascript function

var gblVarId = "";
function handleButton(obj)
{
   obj.value = "Off";
   gblVarId =obj.id;
   return false;
}



还要在动态按钮中添加OnClientClick handler



Also add the OnClientClick handler in dynamic button

dynamicButton1..OnClientClick = "return handleButton(this)";