In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the "tutorial on the value and assignment of RadioButtonList,DropDownList,CheckBoxList on the ASP.NET server side". In the daily operation, I believe that many people have doubts about the value and assignment usage tutorial of how to control RadioButtonList,DropDownList,CheckBoxList on the ASP.NET server side. The editor consulted all kinds of materials and sorted out a simple and useful operation method, hoping to answer "how to control RadioButtonList,DropDownList on the ASP.NET server side." CheckBoxList value, assignment usage tutorial "doubts help!" Next, please follow the editor to study!
All three controls have an Items collection, and you can use the RepeatLayout and RepeatDirection properties to control the rendering of the list. If the value of RepeatLayout is Table, the list is rendered in the table. If set to Flow, the list will be rendered without any table structure. By default, the value of RepeatDirection is Vertical. Setting this property to Horizontal will render the list horizontally.
RadioButtonList: the control provides a single selection list (data source radio) of an option that has been selected. Like other list controls, RadioButtonList has an Items collection whose members correspond to each item in the list.
DropDownList: drop-down list selection. For some forms of input, the user must select an option from the list of applicable options (drop-down only selection).
CheckBoxList: a multi-select list that presents the data source to the user horizontally or vertically, and the user can select multiple item.
Since these three controls are server-side controls and need to be parsed on the client side, here are three server-side and client-side examples of these controls.
Server side
The copy code is as follows:
Choose one by one
Single selection two
Single selection of three
Choose one more.
Choose more than two.
Choose more than three
Drop down and choose one.
Drop-down option two
Drop-down option three
After being parsed by the browser
The copy code is as follows:
Choose one by one
Single selection two
Single selection of three
Choose one more.
Choose more than two.
Choose more than three
Drop down and choose one.
Drop-down option two
Drop-down option three
The operation for these three controls is nothing more than taking values and assigning values, which are done through Jquery and .cs.
Jquery operates on three kinds of controls
1 、 RadioButtonList
1) take a value
The copy code is as follows:
$("# RadioButtonList1") .change (function () {
/ / pops up the vale value of the selected item
Alert ($("input [name = 'RadioButtonList1']: checked") .val ())
/ / pops up the text value of the selected item
Alert ($("input [name = 'RadioButtonList1']: checked+label") .text ())
});
2) assignment
The copy code is as follows:
/ / the second option is selected by default
Var rbts = document.getElementsByName ("RadioButtonList1")
For (var I = 0; I
< rbts.length; i++) { if (rbts[i].value == "1") rbts[i].checked = "true"; } 2、DropDownList 1)取值 复制代码 代码如下: $("#DropDownList1").change(function () { //弹出选中项的Val值 alert($("#DropDownList1").val()); //弹出选中项的text值 alert($("#DropDownList1 option:selected").text()); }); 2)赋值 复制代码 代码如下: //默认选中第二项 var ddls = $("#DropDownList1 option"); for (var i = 0; i < ddl.length; i++) { if (ddl[i].value == "1") { ddl[i].selected = "true"; } } 3、CheckBoxList 1)取值 复制代码 代码如下: $("#CheckBoxList1 >Input ") .click (function () {
Var arrval = []
Var val = ""
$("# CheckBoxList1: checkbox:checked") .each (function () {
/ / put the value of the selected item into the array arrval
Arrval.push ($(this) .val ()
})
/ / concatenate the vals in the array with','
Val = arrval.join (',')
/ / pops up all selected items to connect
Alert (val)
Var arrtext = []
Var text = ""
$("# CheckBoxList1: checkbox:checked") .each (function () {
/ / put the text value of the selected item into the arrtext array
Arrtext.push ($(this). Next (). Html ())
/ / use the data in the array to connect
Text = arrtext.join (",")
})
/ / pops up the text value of the selected item
Alert (text)
});
2) assignment
The copy code is as follows:
Var cbks = $("# CheckBoxList1 input [type = 'checkbox']")
For (var I = 0; I < cbks.length; iTunes +) {
If (CBKS [I] .value = = "1" | | CBKS [I] .value = = "2") {
Cbks [I]. True = "cbks"
}
}
At this point, on the "ASP.NET server-side how to control RadioButtonList,DropDownList,CheckBoxList values, assignment usage tutorial" is over, I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 232
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.