防止页面回发 [英] prevent page post back

查看:64
本文介绍了防止页面回发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Web应用程序中,我已经在每个带有文本打开的单元格中生成了一个动态表并生成了动态按钮,现在我希望在单击按钮时将单击的文本更改为"off",并将行索引的btn id存储在一个变量中

in web application, i have generated a dynamic table and generated dynamic buttons in each cell with text on,now i want that on button clicked text should get changed to "off" and btn id of row index get stored in a variable

推荐答案

您可以使用 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)";


这篇关于防止页面回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆