如何在回发前淡出一行
我有一个在 ASP.Net 的 DataList 中创建的表。 该表具有三个文本字段,然后是一个带有编辑按钮的字段和一个带有删除按钮的字段。 当用户单击删除按钮时,它会发回,删除项目,然后再次绑定 DataList。 DataList 位于 UpdatePanel 中,因此该项目会在半秒或更长时间后平滑消失,但我真正想要的是,一旦按下删除按钮,该行就会滑出(向上),并且然后让它删除回发的项目。
我可以使用 jQuery 使行滑出,但回发会妨碍。 你怎么处理那件事呢?
I have a table that is created in a DataList in ASP.Net. This table has three fields of text, then a field with an edit button, and a field with a delete button. When a person clicks the delete button, it posts back, deletes the items, and then binds the DataList again. The DataList is in an UpdatePanel so the item smoothly disappears after a half of a second or maybe a little more, but what I'd really like is for the row to slide out (up) as soon as they hit the delete button, and then have it delete the item on the post back.
I can make the row slide out with jQuery, but the postback gets in the way. How do you deal with that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用asp.net中的页面方法向服务器发送请求,而无需执行回发。 它们使用起来非常简单,当 ajax 调用完成时你可以做任何你喜欢的效果(你会得到一个成功时调用的函数)。
如果你想坚持回发,一个解决方案如下:
在js中类似:
这有点像黑客,想法是最初取消回发,做一些事情,然后设置一个计时器,在其中启用回发。 这种方法的一个大问题是淡入淡出效果和实际删除是独立的(如果出现错误,您仍然会得到淡入淡出效果)。
You can use page methods in asp.net to send a request to the server without doing a postback. They are very simple to use and you can do whatever effect you like when the ajax call is completed (you get a function called on success).
If you want to stick with the post back one solution is the following:
and in js something like:
It's a bit of a hack, the idea is to cancel the postback initially, do some stuff then set a timer where the postback will be enabled. The big problem with this approach is that the fade effect and the actual delete are independent (in case of an error you still get the fade effect).
您是否尝试过查看任何 Ajax 控件工具包项目? 我相信如果您不太熟悉的话,其中有一些控件将与客户端(java)代码一起使用
have you tried looking at any of the Ajax control toolkit items? I believe there are some controls in there that will head with client side (java) code if your not extremely familiar
我将使用客户端 Javascript 手动将“不透明度”CSS 属性缩放到零,然后将该元素标记为“display: none”,然后提交回发。
我相信在 Internet Explorer 中,您需要使用“Filter”CSS 属性来执行此操作,因为它不支持不透明度。
您可以编写一个例程来设置这两个属性,并且该例程应该涵盖所有主要浏览器。
I would use client side Javascript to manually scale the "opacity" CSS property down to zero, then mark the element as "display: none" then submit the post-back.
I believe that in Internet Explorer, you need to use the "Filter" CSS property to do this as it does not support opacity.
You could just code up a routine to set both properties and that should cover all the major browsers.
注册表单“提交”事件的处理程序。
防止表单提交对于避免干扰您想要执行的效果是必要的。 完成后,您可以继续提交。
Register the handler for form "submit" event.
Preventing form submission is necessary to avoid interference with the effects you want to perform. After they are finished, you are free to proceed with submission.