本文介绍了验证(ASP.NET):属性'onclick'不是元素'dropdownlist'的有效属性。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我在onclick上试试这个下拉列表 我尝试过: < asp:DropDownList ID = DropDownList1 runat = server onselectedindexchanged = DropDownList1_SelectedIndexChanged onclick = Loadchart(); > 但显示错误 验证(ASP.Net):属性'onclick'不是元素'DropDownList'的有效属性。 我在页面加载时调用此下拉列表 DropDownList1.DataSource = getyear(); DropDownList1.DataTextField = year; DropDownList1.DataValueField = year_id; DropDownList1.DataBind(); 当我构建时显示错误任何解决方案解决方案 从标记中删除该事件并在页面中添加绑定事件后面的代码 load。 但是, onchange 事件应该对Dropdownlist事件有帮助。无论如何它符合你的要求。 < asp:dropdownlist id = DropDownList1 runat = 服务器 > OnSelectedIndexChanged =DropDownList1_SelectedIndexChanged> < / asp:dropdownlist > CS protected void Page_Load( object sender,EventArgs e) { if (!IsPostBack) { DropDownList1.Attributes.Add( onclick, Loadchart(); ); } } i try this dropdown list with onclickWhat I have tried:<asp:DropDownList ID="DropDownList1" runat="server" onselectedindexchanged="DropDownList1_SelectedIndexChanged" onclick="Loadchart();">but this shows errorValidation (ASP.Net): Attribute 'onclick' is not a valid attribute of element 'DropDownList'.where as i call this dropdown on page loadDropDownList1.DataSource = getyear(); DropDownList1.DataTextField = "year"; DropDownList1.DataValueField = "year_id"; DropDownList1.DataBind();When i build this shows error any solution 解决方案 Remove that event from mark up and add bind the event from code behind during pageload.however, onchange event should helpful in case of Dropdownlist events. anyhow its upto your requirement.<asp:dropdownlist id="DropDownList1" runat="server" > OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:dropdownlist>CSprotected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.Attributes.Add("onclick", "Loadchart();"); } } 这篇关于验证(ASP.NET):属性'onclick'不是元素'dropdownlist'的有效属性。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-28 17:07