DropdownList 重置在更新面板的提交按钮上不起作用

发布于 2024-09-26 10:46:54 字数 918 浏览 0 评论 0原文

我有一个位于更新面板中的下拉列表。我必须通过 JavaScript 来填充客户端事件上的下拉列表,该 JavaScript 调用 updatepanel 的 __dopostback 并调用其加载事件。

问题是,当我提交表单时, updatepanel_Load 事件也会再次执行,并再次重置 DropDownLIst ,这会导致 Dropdown 中的 selectedValue 丢失。

<asp:UpdatePanel  ID="UpdatePanel3" runat="server" OnLoad="UpdatePanel3_Load" UpdateMode="Conditional">

   <ContentTemplate>


       <asp:DropDownList ID="ddlItems" runat="server" CssClass="dropdown">                  
       </asp:DropDownList>                 

   </ContentTemplate>
</asp:UpdatePanel>

在“加载”页面上,此下拉列表为空...没有功能可以填充它。

现在的问题是,每当我通过 UPatepanel 的 Load 填充下拉菜单时,UPatepanel Load 事件也会在我提交页面时执行。实际上,JavaScript 的解决方案是由于一个表,并且在选择表行项目时,它会填充我的 updatepanel 的 __dopostback 中的 DropDownList。

我有一个按钮可以打开一个弹出窗口,并且该弹出窗口包含一个表格,当客户端从该表格中选择某些项目并关闭该弹出窗口时,我将填充下拉列表(通过 Ajax、Updatepanel 的加载在父级或开启器页面中)作为进一步的选择选项。因此下拉数据绑定取决于该表输入。

I have a dropdown list which is in updatepanel. I have to fill that dropdown on a client event through JavaScript which calls __dopostback of the updatepanel and calls its load event.

Problem is that when I submit the form updatepanel_Load event also execute again and it again reset the DropDownLIst which causes the loss of selectedValue in Dropdown.

<asp:UpdatePanel  ID="UpdatePanel3" runat="server" OnLoad="UpdatePanel3_Load" UpdateMode="Conditional">

   <ContentTemplate>


       <asp:DropDownList ID="ddlItems" runat="server" CssClass="dropdown">                  
       </asp:DropDownList>                 

   </ContentTemplate>
</asp:UpdatePanel>

On page Load this dropdown is Empty .... no function to fill it.

Now the problem is when ever I Fill the Dropdown through Load of UPatepanel, that UPdatepanel Load event also execute when I submit my page. Actually the solution of JavaScript is due to a table and on Selection of the table row item it Fills the DropDownList from __dopostback of my updatepanel.

I have button which opens a popup window and that popup window contains a table, when client select some item from that table and close that popup window then I fill my dropdown (in parent or opener page through Ajax, Updatepanel's Load) as further selction option. so dropdown databind is dependent on that tables input.

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

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

发布评论

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

评论(2

望笑 2024-10-03 10:46:54

你的页面加载情况如何?如果您在页面加载中加载 ddl,则每次点击都会加载项目。使用;

If Not Page.IsPostBack then

What about your page load? If you are loading your ddl in your page load, you load items on every click. Use;

If Not Page.IsPostBack then
梦回梦里 2024-10-03 10:46:54

我必须用 JavaScript 来处理它。因此,我在隐藏字段中的 onchange 事件上将所选值保存在 DropDownList 上,并从该隐藏字段中保存,因为在保存事件时下拉列表会重置并丢失所选项目。

因为我观察到,当我单击“保存”按钮时,所使用的回调事件也会在按钮单击事件之前调用。因此,就我而言,它会重置下拉菜单。

I have to handle it with javascript. So I save the selected value on DropDownList on onchange event in Hidden field and save from that hidden field because at save event dropdown gets reset and lost the selected item.

Because I observed that when I clicked save button the callback events which used also called before button click event. So as my case it resets the Dropdown.

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