asp.net 如何获取html控件select

只有设置了 runat="server" ,在后台才可以访问。

示例:




    无标题页


   


       
       

   

   



代码:

                foreach ( ListItem item in mySelect.Items )
                {
                    myDiv.InnerHtml += string.Format( "Text = {0}, Value = {1}
", item.Text, item.Value );
                }
或者:
                for ( int i = 0; i < mySelect.Items.Count; i++ )
                {
                    myDiv.InnerHtml += string.Format( "Text = {0}, Value = {1}
", mySelect.Items[ i ].Text, mySelect.Items[ i ].Value );
                }

你可能感兴趣的:(asp.net 如何获取html控件select)