客户端的部分回发和操作

发布于 2024-07-22 06:27:39 字数 288 浏览 5 评论 0原文

我有两个 DropDownList。 第一个是可见的,第二个是不可见的。 我想要这样的东西:

  1. 从第一个 DDL 中选择值。
  2. 然后发生部分回发 - 根据选择从数据库检索数据。
  3. 第二个 DDL 已填充
  4. 第二个 DDL 显示为 ie 幻灯片效果 (javascript)

我不想进行完整的回发。 最终的效果应该是:

从第一个DDL中选择值,然后在下面,向下滑动填充的第二个DDL。

我不知道如何开始。

I've got two DropDownLists. First is visible and second is not. I'd like to have something like this:

  1. Select value from first DDL.
  2. Then partial postback occurs - the data is retrieved from DB based on selection.
  3. Second DDL is populated
  4. Second DDL is shown with i.e. slide effect (javascript)

I don't want to have full postback. The final effect should be:

Select value from first DDL and then below, slides down second DDL which is populated.

I don't have a clue how to start.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

落叶缤纷 2024-07-29 06:27:39

由于听起来您使用的是 Web 表单,因此解决问题的第一步是您首先研究 ASP.Net UpdatePanel 控件及其提供的选项。

http://msdn.microsoft.com/en- us/library/system.web.ui.updatepanel.aspx

忠告 不过,UpdatePanel 乍一看看起来不错,但它通过网络发送的数据比必要的多 100 倍,并且 Ajax 越多,很快就会变得执行缓慢。你做的事情。 一旦功能变得复杂,由于性能问题,您真的可以将自己的代码陷入困境。

我会看一下 encosia.com 上有关如何将 jQuery 与 Asp.net WebForms 结合使用的精彩教程,看看您是否可以学习该方法。 UpdatePanel 并不是一个很好的工具,您会对 jQuery 提供的功能感到惊讶。

http://encosia .com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/

您还提到您想要“幻灯片”效果。 我认为要做到这一点,您必须深入研究 asp.net ajax 动画扩展器,而该框架使用起来并不漂亮或令人愉快。

Since it sounds like your using webforms the first step to solving your problem would be for you to first research the ASP.Net UpdatePanel control and the options it provides.

http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.aspx

Word of Advice though, UpdatePanel looks great at first glance but it sends 100 times more data across the wire than necessary and quickly becomes a slow performing mess the more Ajax stuff you do. You can really code yourself into tight corners because of the performance issues once the functionality gets complicated.

I'd take a look at the great tutorials on encosia.com on how to use jQuery with Asp.net WebForms and see if you can learn that method instead. UpdatePanel isn't that great of a tool and you'll be amazed with what jQuery can provide.

http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/

Also you mentioned you wanted a "slide" effect. I think to do that you'll have to dive into the asp.net ajax animation extenders stuff and that framework is not pretty or pleasant to work with.

且行且努力 2024-07-29 06:27:39

您可以从使用 UpdatePanel 开始。 您可以更新事件以仅更新 UpdatePanel 中包含的内容。

官方链接 ASP UpdatePanel 概述

You can start by using UpdatePanel. You can update events to update only the content included in the UpdatePanel.

Offical Link ASP UpdatePanel Overview

坚持沉默 2024-07-29 06:27:39

使用 UpdatePanel 是在 ASP.NET 中获取 AJAX 行为的简单方法。 UpdatePanel 将为您处理大部分 AJAX。

这是一个很好的教程:

http://www.asp.net/Ajax /Documentation/Live/tutorials/IntroductionUpdatePanel.aspx

Using an UpdatePanel is an easy way to get AJAX behavior in ASP.NET. The UpdatePanel will handle most of the AJAX for you.

Here's a good tutorial:

http://www.asp.net/Ajax/Documentation/Live/tutorials/IntroductionUpdatePanel.aspx

岛徒 2024-07-29 06:27:39

您应该查看

级联下拉列表

并使用 jQuery 进行更改第二个下拉列表的 div,
请参阅此处

和相关的 jQuery

<script type="text/javascript">
$(document).ready(function(){

$(".btn-slide").click(function(){
    $("#panel").slideToggle("slow");
    $(this).toggleClass("active"); return false;
});


});

You should look at

Cascading Drop Down

and using jQuery to change the div of the second dropdown,
See here

and the relevant jQuery

<script type="text/javascript">
$(document).ready(function(){

$(".btn-slide").click(function(){
    $("#panel").slideToggle("slow");
    $(this).toggleClass("active"); return false;
});


});

西瑶 2024-07-29 06:27:39

也许 Ajax 控件工具包中的 Cascading Dropdown 控件可以帮助您:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ CascadingDropDown/CascadingDropDown.aspx

Maybe Cascading Dropdown control from Ajax control toolkit can help you:
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDown.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文