如何防止网格中按钮的回发事件 [英] how to prevent postback event for button in a grid

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

问题描述



我有一个数据网格,里面有一个模板项目,它是按钮。我想

当用户点击按钮时做一些事情,但不希望发生回发事件

。我该怎么办?

谢谢。


william

解决方案

"????= UTF-8乙d2lsbGlhbQ == = QUOT; <无线***** @ discussions.microsoft.com>承认

新闻:04 ********************************** @ microsof t .com:


我有一个数据网格,里面有一个模板项目,它是按钮。我想在用户点击按钮时做一些事情,但不希望发生回发
事件。我怎么能这样做?
谢谢。

威廉




你必须做点什么。也许你只想使用一个直接的HTML控件

并将它的onclick事件属性挂钩到客户端javascript?


-


>我有一个数据网格,里面有一个模板项目,它是按钮。我想

当用户点击按钮时做一些事情,但不希望回发
事件发生。我怎么能这样做?




好​​吧,既然ASP:Button是一个服务器端控件,就没有非回发

功能在上面。如果你点击它,它就会回发。


所以你只限于客户端代码。只有按钮控件来处理

客户端代码而不是回发,是一个HTML按钮,您可以在工具箱的HTML选项卡中找到它。像这样:


< script language =" javascript">

函数myJavaScriptFunction(){

// do这里的一些东西

}

< / script>


.....然后在你的HTML身体的某个地方。 ...:


< input type ="按钮" value ="点击我! onclick =" myJavaScriptFunction();">


那对你有帮助吗?

Jeppe Jespersen

jdj-jdj .dk


" william" <无线***** @ discussions.microsoft.com>在消息中写道

news:04 ********************************** @ microsof t.com ...


我有一个数据网格,里面有一个模板项目,它是按钮。我想在用户点击按钮时做一些事情,但不希望发生回发
事件。我怎么能这样做?




将它设为客户端按钮(没有runat =" server")。

< input类型= QUOT按钮"的onclick = QUOT;将myHandler();" >


Jos


Hi,
I have a datagrid, inside there is a templete item, it''s button. I want to
do some thing when user click the button, but do not want the postback event
happens. How can I do it?
Thanks.

william

解决方案

"=?Utf-8?B?d2lsbGlhbQ==?=" <wi*****@discussions.microsoft.com> confessed in
news:04**********************************@microsof t.com:

Hi,
I have a datagrid, inside there is a templete item, it''s button. I want to
do some thing when user click the button, but do not want the postback event happens. How can I do it?
Thanks.

william



You gotta do something. Maybe you just want to use a straight HTML Control
and hook it''s onclick event property to client-side javascript?

--


> I have a datagrid, inside there is a templete item, it''s button. I want to

do some thing when user click the button, but do not want the postback event happens. How can I do it?



Well, since an ASP:Button is a server side control, there is no non-postback
functionality on it. If you click it, it will postback.

So you''re limited to client side code. Only button control to handle
clientside code and not postback, is an HTML Button, which you''ll find in
the HTML tab of your toolbox. Like this:

<script language="javascript">
function myJavaScriptFunction() {
//do some stuff here
}
</script>

.....and then in your HTML body somewhere....:

<input type="Button" value="Click me!" onclick="myJavaScriptFunction();">

That help you any?
Jeppe Jespersen
jdj-jdj.dk


"william" <wi*****@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...

Hi,
I have a datagrid, inside there is a templete item, it''s button. I want to
do some thing when user click the button, but do not want the postback event happens. How can I do it?



Make it a client-side button (no runat="server").
<input type="button" onclick="myHandler();" >

Jos


这篇关于如何防止网格中按钮的回发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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