下拉列表的属性 [英] Property of Dropdownlist

查看:102
本文介绍了下拉列表的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生您好,

我正在做一个cdoe,其中我很好地使用了Dropdownlist,因为我们知道dropdownlist中不存在一个名为onchange的属性,但是当我们调用任何函数时,它如何工作却为什么不给出错误,因为使用了任何其他控件都给出错误,为什么这是带有dropdown的onchange属性的原因

Hello sir,

I was doing one cdoe in which I used Dropdownlist well as we know that there is a property named onchange doesn''t exist in dropdownlist but when we call any function it works how why it doesn''t gives error because using any field in any other control gives error why this is with onchange property of dropdown

<asp:Dropdownlist ID="ddlProject" runat="Server" AutoPostback="true" Onchange="return Restrict();" >



请告诉onchange是否在dropdwon的属性中不存在,当我们运行程序时它如何执行



Please tell if onchange doesn''t exist in property of dropdwon how it execute when we run our program

推荐答案

dropdowlist有一个名为selectedindexchanged的事件,可以用来做你的事情

dropdowlist has an event called selectedindexchanged use that to do your stuff

 protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
{
//your code
}


实际上,在dropdownlist类中未定义onchange属性.每当您指定不是有效属性的东西时,它都会按html中的形式呈现.由于OnChange是html的select标记中的有效元素,因此您可以在更改dropdownlist时获得javascript响应.
尝试使用此代码,然后查看呈现的html页面.


Actually the onchange property is not defined in the dropdownlist class. when ever you specify some thing that is not a valid property , it is rendered as it is in html.As OnChange is a valid element in select tag of html you are able to get the javascript response when you change the dropdownlist.
try this code and see the html page rendered.


<asp:dropdownlist id="ddl" onchange=" a()" onabc="a()" runat="server">


onchangeonselectedIndexChanged都是不同的事件.
onchange基本上是客户端事件(用于脚本编写),它与代码隐藏代码无关.

其中, onselectedIndexChanged 是代码隐藏事件,仅在AutoPostback为true时调用.
onchange and onselectedIndexChanged both are different events.
onchange is basically a client side event (used for scripting) , which has nothing to do with codebehind code.

whereAs, onselectedIndexChanged is codebehind event, called only when AutoPostback is true.


这篇关于下拉列表的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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