Javascript Asp.net dropdownlist Onselectedindexchanged事件
我的asp.net页面中有一些动态控件Javascript Asp.net dropdownlist Onselectedindexchanged事件,javascript,asp.net,events,drop-down-menu,Javascript,Asp.net,Events,Drop Down Menu,我的asp.net页面中有一些动态控件 DropDownList Exsecondpositiontxtbox = new DropDownList(); Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString(); 像 TextBox ratingtxtbox = new TextBox(); ratingtxtbox.ID = "Rating_1"; DropDownList Exsecondpositiontxtbox = new D
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
像
TextBox ratingtxtbox = new TextBox();
ratingtxtbox.ID = "Rating_1";
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
及
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
对于我的文本框,我将keyup事件添加为
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
ratingtxtbox.Attributes.Add("onkeyup", "ChangebyWin(" + i.ToString()+")");
它工作得很好
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
现在我添加了下拉列表的Indexchange事件作为
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
Exsecondpositiontxtbox.Attributes.Add("onselectedindexchanged", "ChangebyExacta(" + i.ToString() + ")");
但是它不起作用。。是因为Key name.中的错误吗?试试这个
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
Exsecondpositiontxtbox.Attributes.Add("onchange", "ChangebyExacta(" + i.ToString() + ")");
您应该改用
onchange
OnSelectedIndexChanged
是一个服务器端事件
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
Exsecondpositiontxtbox.Attributes.Add("onchange", "ChangebyExacta(" + i.ToString() + ")");
以下是如何在SelectedIndexChanged上使用
DropDownList Exsecondpositiontxtbox = new DropDownList();
Exsecondpositiontxtbox.ID = "Exacta2nd_" + i.ToString();
Exsecondpositiontxtbox.SelectedIndexChanged += SomeEventHandler;
你真的需要分享你的javascript代码。您是否还在这些控件上使用clientdmode=Static
?因为除非您是,否则它实际上不会是ID。请尝试更改一次,而不是更改选定的索引。