Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Asp.net dropdownlist Onselectedindexchanged事件_Javascript_Asp.net_Events_Drop Down Menu - Fatal编程技术网

Javascript Asp.net dropdownlist Onselectedindexchanged事件

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

我的asp.net页面中有一些动态控件

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。请尝试更改一次,而不是更改选定的索引。