动态填充DropDownList,AutoPostback和JavaScript错误 [英] Dynamically populating a DropDownList, AutoPostback and JavaScript error

查看:58
本文介绍了动态填充DropDownList,AutoPostback和JavaScript错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我正在尝试使用asp.net创建一个请求表单,当用户选择一个复选框时,下拉列表应该动态显示。我在网上看过很少的java脚本,但我想知道如果没有java脚本我是否能实现这个目标。


我试图使控件不可见(< asp:DropDownList ID =" DropDownList1" runat =" server" AppendDataBoundItems =" True" Visible =" False ">)并且在onselectedindexchanged事件中,尝试将invisible属性设置为true。但它没有帮助我。

另外,当我选择一个复选框时,我试图使用页面回发(asp:CheckBoxList ID =" chckbx" runat =" server" AutoPostBack =" ; true" onselectedindexchanged =" chckbx_SelectedIndexChange d")并且它在IE中抛出一个错误,说该对象不支持此属性。



有人可以请帮助我这个。在此先感谢。

hello,

i am trying to create a request form using asp.net where when a user selects a checkbox, a dropdown should appear dynamically. I have seen few java-scripts in web, but I was wondering if I can achieve this without java-script.

I tried to make the control invisible(<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" Visible="False">) and in the onselectedindexchanged event, tried to make the invisible property to true. But it did not help me.
Also, I was trying to use postback for the page when a checkbox is selected(asp:CheckBoxList ID="chckbx" runat="server" AutoPostBack="true" onselectedindexchanged="chckbx_SelectedIndexChange d") and it throws me an error in IE saying the object does not support this property.


Can somebody please help me with this. Thanks in advance.

推荐答案

在继续之前,请看一下这篇文章:
如何在ASP.NET中使用动态控件


-Frinny
Before you continue please take a look at this article on:
How to use dynamic controls in ASP.NET.

-Frinny


感谢您的回复。


我能够理解链接中的示例,但无法真正将其放入为我的场景工作。
thank you for the reply.

I am able to understand the example in the link but could not really put it into working for my scenario.


好的,在你的场景中,当用户选中一个复选框时你需要这样做。

我假设你需要根据用户检查的内容填充下拉列表。


这不是动态创建控件。


你需要什么要做的是动态填充下拉列表。


您目前有什么可以作为起点?


-Frinny

(PS请发布代码代码标签
Ok, in your scenario you need to do this when the user checks a checkbox.
I''m assuming that you need to populate the drop down list with items depending on what the user has checked.

This is not dynamically creating a control.

What you need to do is dynamically populate the drop down list.

What do you have currently that we can use as a starting point?

-Frinny
(PS please post code in code tags)


这篇关于动态填充DropDownList,AutoPostback和JavaScript错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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