将javascript window.confirm添加到linkbutton [英] adding javascript window.confirm to linkbutton

查看:67
本文介绍了将javascript window.confirm添加到linkbutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能从链接按钮抢占用于回发的javascript函数




我想使用linkbutton删除记录并想通过javascript添加确认

框你确定要删除此记录吗?在它之前

执行回发。 javascript是直截了当的,但有

不知道如何截取回发后的脚本。


-Darrel

解决方案

" darrel" < no ***** @ nowhere.com写了留言

新闻:%2 **************** @ TK2MSFTNGP02.phx.gbl .. 。


是否有可能抢占用于回复的javascript函数
来自链接按钮的



我想使用linkbutton删除记录,并希望通过javascript添加

确认框你确定要删除这个

记录?在它执行回发之前。这个javascript是直接的,但是不知道怎么拦截

的回发后脚本。



任何返回false的JavaScript函数都会拦截回发,例如


< asp:Button ID =" MyButton" RUNAT = QUOT;服务器" OnClick =" MyButton_Click"

OnClientClick =" return confirm(''您确定要删除此

记录吗?'');"文本= QUOT;删除" />


在上面的示例中,当用户点击删除按钮时,它们将以客户端提示是/ b $ b提示是/否警报 - 如果他们单击是,则回发

将发生并运行服务器端MyButton_Click方法中的代码 - 如果

他们点击否,回发将被截获,没有任何内容

将会发生...

-

Mark Rae

ASP.NET MVP
http://www.markrae.net


< asp:Button ID =" MyButton" RUNAT = QUOT;服务器"的OnClick = QUOT; MyButton_Click"


OnClientClick =" return confirm(''你确定要删除这个

记录吗?'');"文本= QUOT;删除" />



光滑,但这可以通过linkBut​​ton完成吗?我没有看到OnClientClick

属性。


-Darrel


" ;达雷尔" < no ***** @ nowhere.comwrote in message

news:u9 ************** @ TK2MSFTNGP05.phx.gbl ...


>< asp:Button ID =" MyButton" RUNAT = QUOT;服务器" OnClick =" MyButton_Click"
OnClientClick =" return confirm(''您确定要删除此
记录吗?');"文本= QUOT;删除" />



光滑,但这可以通过linkBut​​ton完成吗?我没有看到

OnClientClick属性。



是的 - 在Page_Load中,添加以下代码:

MyLinkBut​​ton.Attributes.Add(" onclick", 返回确认(''你确定你想要删除这条记录吗?'b $ b。'););

-

Mark Rae

ASP.NET MVP
http:// www .markrae.net


Is it possible to pre-empt the javascript function used to do a postback
from a linkbutton?

I''d like to use linkbutton to delete a record and want to add a confirmation
box via javascript "are you sure you want to delete this record?" before it
executes the postback. The javascript is straightforward for this, but have
no idea how to have that intercept the post-back script.

-Darrel

解决方案

"darrel" <no*****@nowhere.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...

Is it possible to pre-empt the javascript function used to do a postback
from a linkbutton?

I''d like to use linkbutton to delete a record and want to add a
confirmation box via javascript "are you sure you want to delete this
record?" before it executes the postback. The javascript is
straightforward for this, but have no idea how to have that intercept the
post-back script.

Any JavaScript function which returns false will intercept a postback e.g.

<asp:Button ID="MyButton" runat="server" OnClick="MyButton_Click"
OnClientClick="return confirm(''Are you sure you want to delete this
record?'');" Text="Delete" />

In the above example, when a user clicks on the Delete button, they will be
prompted with a client-side Yes/No alert - if they click Yes, the postback
will happen and run the code in the server-side MyButton_Click method - if
they click No, the postback will be intercepted and nothing further will
happen...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


<asp:Button ID="MyButton" runat="server" OnClick="MyButton_Click"

OnClientClick="return confirm(''Are you sure you want to delete this
record?'');" Text="Delete" />

Slick, but can this be done with a linkButton? I don''t see an OnClientClick
property for that.

-Darrel


"darrel" <no*****@nowhere.comwrote in message
news:u9**************@TK2MSFTNGP05.phx.gbl...

><asp:Button ID="MyButton" runat="server" OnClick="MyButton_Click"
OnClientClick="return confirm(''Are you sure you want to delete this
record?'');" Text="Delete" />


Slick, but can this be done with a linkButton? I don''t see an
OnClientClick property for that.

Yep - in the Page_Load, add the following code:

MyLinkButton.Attributes.Add("onclick", "return confirm(''Are you sure you
want to delete this record?'');");
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


这篇关于将javascript window.confirm添加到linkbutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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