ASP.Net 从代码后面模拟淡出效果?
我有一个代码将标签的文本设置为代码后面的内容,并且我希望该标签在一段时间后消失?我尝试过 jQuery,但不想使用计时器来不断检查是否有文本,然后将其隐藏:(。我听说过 Ajax Toolkit for ASP.Net,但许多评论说,现在并非所有工具都可以正常工作。所以有人知道这个问题有什么好的解决方案
吗?
I have a code that set the text of a label to something from code behind and I want that label to disappear after some times? I've tried jQuery but don't want use timer to keep checking if there is text then hide it :(. I heard about the Ajax Toolkit for ASP.Net but many reviews said that not all of the tools working properly now anymore. So anyone know a good solution for this?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想在一段时间后达到这种效果,那么应该运行一个计时器。您可以使用 setTimeout 方法来执行此操作,
这将在 1 秒后淡出您的标签。
If you want that effect after a time, then a timer should run. You can use setTimeout method to do this
This will fadeout your label after 1 second.
假设您想要做的是在代码隐藏中分配文本后不久淡出标签...
您可以将标签包装在 ASP.NET UpdatePanel 中。从 Ajax 控制工具包 添加一个 AnimationExtender。当您更新代码隐藏中的文本时,调用更新面板的 Update() 方法并让它调用脚本 OnUpdated。
在后面的代码中:
然后只需在页面的脚本标记中添加一个名为 fadeOut() 的方法即可执行淡入淡出。
Assuming that what you want to do is fade out the label shortly after you assign the text in code-behind...
You could wrap the label in an ASP.NET UpdatePanel. Add an AnimationExtender from the Ajax Control Toolkit. When you update the text in your code-behind, call the Update() method of the Update Panel and have that call a script OnUpdated.
In your code behind:
Then just have a method called fadeOut() within script tags in your page that performs the fade.