1. Deep copy and shortest copy of datatable
Assume that a datatable object table is known.
Datatable copydatatable; copydatatable = table. Copy (); // copy the structure and data of the datatable. Copydatatable = table; // a copy is a reference.
2. deduplication of datatable
Assume that a datatable object table is known. It has three columns: column1, column2, and column3. And the data of this able is not obtained from the database. So how can we remove the duplicate data in this able?
The method is as follows:
Dataview = new dataview (table); datatable = dataview. totable (true, new string [] {"column1", "column2", "column3 "});
3. Obtain the text value of the server control set to readonly.
Take textbox as an example. For example, <asp: textbox id = "txtinfo" runat = "server" readonly = "true"> </ASP: textbox>, although this control can be assigned a value through JS. CS file txtinfo. the text value is always a null string.
Solution:
Instead of using the readonly attribute of the server control, txtinfo is used in page_load. attributes ["readonly"] = "true"; implements readonly, and then uses txtinfo. text to get the value of text.
4. How to achieve the effect of page blackening during page loading
Method 1: Use blockui plugin of jquery.
Method 2: Use the following HTML and control its display with Js.
HTML + CSS to achieve this effectCode:
<Div id = "fadediv" style = "Z-index: 100; position: absolute; display: none; width: 100%; Height: 1000px; Background-color: #0060c0; filter: alpha (opacity = 20); text-align: center; "> </div>
JS method:
Document. getelementbyid ("fadediv"). style. Display = "Block"; // display document. getelementbyid ("fadediv"). style. Display = "NONE"; // hide
5. Obtain the selected values (Value and text) in the select box) Select Server Control:
<Select id = "select1" runat = "server">
<Option value = "1" selected = "selected"> 1 </option>
<Option value = "2"> 2 </option>
</SELECT>
C # method:
String strvalue = select1.value; // The value is "1" (that is, the value) string strtext = select1.items [select1.selectedindex]. tostring (); // The value is "1" (that is, the text value)
JS method:
VaR selectobj = document. getelementbyid ("select1"); var strvalue = selectobj. value; // The value is "1" (that is, the value) var strtext = selectobj. options (selectobj. selectedindex ). text; // The value is "1" (that is, the text value)
Jquery method:
$ ("# Select1 "). val (); // The value is "1" (value) $ ("# select1 option: Selected "). val (); // The value is "1" (value) $ ("# select1> Option: Selected "). get (0 ). text; // The value is "1" (that is, the text value)