In the evening, I learned about single-choice controls and single-choice group controls, Check controls, and check group controls.
A little bit of brains, made a small web page program. The main function is to assign values to each other. The font size and color of the tag have been set to the front and back background colors.
Main functions:
1. Enter text in the text input box. After submission, you can assign values to tags;
2. You can assign values to tags by selecting a single sequence;
3. You can set the color of the tag when selecting a single-choice group control;
4. You can set the font size when selecting the radio group control.
The final effect is as follows:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/2B/wKioL1QQYBDw_m8PAAHGPBoFgRo696.jpg "Title =" 1.png" alt = "wkiol1qqybdw_m8paahgpbofgro696.jpg"/>
I will not talk about the block setting. Let's see which modules are used:
1. a custom method is provided to assign the tag value to the input box. Make the content in the input box consistent with the label content.
This method is simple but easy to use.
// Setting method, so that the label text is the same as the textbox text, that is, to assign a public void labletotextbox (string lablevalue) {textbox1.text = lablevalue;} to the input box ;}
2. Other actions and events that directly use the control are as follows:
// After entering the text, assign the text to the label. Protected void button#click (Object sender, eventargs e) // use the check group to set the color of the label's font. Protected void encode (Object sender, eventargs e) // judge a single struct (checkbox1 and checkbox2) and assign the value of protected void checkbox1_checkedchanged (Object sender, eventargs E) to the label and input box. // set the font size of the sub-label. Protected void checkboxlist1_selectedindexchanged (Object sender, eventargs E)
3. The Code is as follows:
Using system; using system. drawing; // Add the color control namespace using system. collections. generic; using system. LINQ; using system. web; using system. web. ui; using system. web. UI. webcontrols; namespace webapplication2 {public partial class webform1: system. web. UI. page {protected void page_load (Object sender, eventargs e) {}// assign the input text to the tag. Protected void button#click (Object sender, eventargs e) {label1.text = textbox1.text;} // set the color of protected void radiobuttonlist#selectedindexchanged (Object sender, eventargs E) {If (radiobuttonlist1.selectedvalue = "red") {label1.forecolor = color. red;} If (radiobuttonlist1.selectedvalue = "green") {label1.forecolor = color. green;} If (radiobuttonlist1.selectedvalue = "***") {label1.f Orecolor = color. yellow; label1.backcolor = color. black ;}}// set the label text to the same text as the textbox text, that is, assign the label public void labletotextbox (string lablevalue) to the input box {textbox1.text = lablevalue ;} // determine the selection status of a single vertex (checkbox1 and checkbox2) and assign protected void checkbox1_checkedchanged (Object sender, eventargs E) to the tag and input box {If (checkbox1.checked = true) {label1.text = "checkbox1 is selected. "; Labletotextbox (label1.text);} If (checkbox1.checked = false) {label1.text =" cancel the selected status of checkbox1. "; Labletotextbox (label1.text) ;}} protected void checkbox2_checkedchanged (Object sender, eventargs e) {If (checkbox2.checked = true) {label1.text =" checkbox2 was selected. "; Labletotextbox (label1.text);} If (checkbox2.checked = false) {label1.text =" cancel the selected status of checkbox2. "; Labletotextbox (label1.text) ;}// set the font size of the subtab protected void checkboxlist1_selectedindexchanged (Object sender, eventargs e) {If (checkboxlist1.items [0]. selected) {label1.font. size = fontunit. small;} else if (checkboxlist1.items [1]. selected) {label1.font. size = fontunit. xlarge;} else if (checkboxlist1.items [2]. selected) {label1.font. size = fontunit. xxlarge ;}}}}
Let's take a look at the effect after running:
The main interface after running is refreshing:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/2B/wKioL1QQYeSzhiVSAAEe1pCXrg8669.jpg "Title =" 2.png" alt = "wkiol1qqyeszhivsaaee1pcxrg8669.jpg"/>
1. Enter text in the text input box. After submission, you can assign values to tags;
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/2A/wKiom1QQYiiCySnwAAFpFgZF72k846.jpg "Title =" 3.png" alt = "wkiom1qqyiicysnwaafpfgzf72k846.jpg"/>
2. You can assign a value to a tag by selecting a single sequence. After checkbox2 is selected, the content of the tag and the input box is changed to the corresponding value:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/49/2A/wKiom1QQYomxGGSCAAErapcRr2o875.jpg "Title =" 4.png" alt = "wkiom1qqyomxggscaaerapcrr2o875.jpg"/>
3. You can set the color of the tag when selecting a single-choice group control;
Set it to red first, while red does not set the background color:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/49/2A/wKiom1QQYtOSp0CdAAFaXxSm14c683.jpg "Title =" 5.png" alt = "wkiom1qqytosp0cdaafaxxsm14c683.jpg"/>
When it is set to ***, *** sets a black background color:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/49/2B/wKioL1QQYxqCKGgBAAFVF4iEzlg174.jpg "Title =" 6.png" alt = "wkiol1qqyxqckggbaafvf4iezlg174.jpg"/>
4. You can set the font size when selecting the radio group control. In fact, the text size has been set in step 3. With the maximum font set, I will set it to the medium Font:
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/49/2B/wKioL1QQY3CwC0-eAAFTXDB_o28174.jpg "Title =" 7.png" alt = "wKioL1QQY3CwC0-eAAFTXDB_o28174.jpg"/>
Haha, the above is all the content, isn't it interesting? C # is really amazing. No, it should be said that ASP. NET is really amazing.
This article from the "Xiaofeng to be a great god" blog, please be sure to keep this source http://felix520cy.blog.51cto.com/7129746/1550929
C # learning notes (20140910)-single-choice controls and single-choice group controls, Check controls, and check group controls