使用jQuery与回传ASP.NET Web窗体 [英] Using jQuery with ASP.NET web forms on postback

查看:153
本文介绍了使用jQuery与回传ASP.NET Web窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过很多很好的博客文章与ASP.NET Web形式利用数据访问功能集成jQuery的,但我很好奇,想知道这将是多么容易回发前使用一些jQuery的动画功能。我能想到的两个很好的例子:

I've read plenty of good blog posts on integrating jQuery with ASP.NET web forms to utilize the data access capabilities, but I'm curious to know how easy it would be to use some of jQuery's animation capabilities before a postback. I can think of two good examples:

1)当我点击一个ASP:?按钮,动画一个div,但后来做的时候动画完成后定期回发(或完成动画的回发后)

1) When I click on a asp:button, animate a div, but then do a regular postback when the animation is finished (or complete the animation after the postback?).

2)当我在GridView中点击一个LinkBut​​ton,淡出gridview的行,然后做在LinkBut​​ton的onclick事件的常规回发。

2) When I click on a linkbutton in a gridview, fade out the gridview row, then do the regular postback in the linkbutton's onclick event.

我不知道解决这个的。我用尽了一切有两种运行回传动画甚至开始之前,或运行动画,但则需要在JavaScript中(呸)。

I'm not aware of a solution to this. Everything I've tried has either run the postback before the animation even starts, or runs the animation but then you need to execute the postback in JavaScript (yuck).

推荐答案

是的,当然你可以做到这一点。

Yes, of course you can do that.

说,例如,我们需要一个按钮做一些回传,

Say for example we take a button to do some postback,

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

onclick事件 - 导致在服务器端进行处理回发

OnClick Event - cause the postback to be processed on the server side.

但是,如果你还定义了的OnClientClick 事件并调用任何JavaScript函数返回值呼叫。这将决定后执行JavaScript函数后回来。

But if you also define a OnClientClick event and call any JavaScript function with a return value to the call. It will decide the post back after the JavaScript function is executed.

例如,

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" OnClientClick="return DoJqueryAnimations();" />

在上面的例子 - DoJQueryAnimations()是一个JavaScript函数。我们与一个称之为重返

In above example - DoJQueryAnimations() is a JavaScript function. We call it with a "return:".

所以,当函数被调用,并决定如何返回,回传将等待客户端功能赋予价值 - 真(做回发)/ false(不回发)

So when the function is called and decides what to return, the postback will wait for the client function to give the value - true(do postback) / false (no post back).

在JavaScript函数你做的动画并返回true。

In the JavaScript function you do the animation and return true.

例如:

function DoJqueryAnimations()
{
    //Do some animations here or call other JavaScript function.
    return true;
}

这篇关于使用jQuery与回传ASP.NET Web窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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