8. DropdownList: Select the drop -down box alone. You have two ways to increase the selection items in the drop -down box. One is the same as the traditional select. Like the Option item, like the following: below:
<ASP: DropdownList ID = Dropdown1 Runat = Server>
<ASP: listitem> item 1 </asp: listitem>
<ASP: listitem> item 2 </asp: listitem>
<Asp: listitem> item 3 </asp: listitem>
<ASP: listitem> item 4 </asp: listitem>
<ASP: listitem> item 5 </asp: listitem>
<ASP: listitem> item 6 </asp: listitem>
</asp: DropdownList>
Another method is to bind data, as follows:
arraylist valueS = New ArrayList ();
Values.add (in);
Values.add (KS);
Values.add (MD);
Values.add (mi);
Values.add (OR);
Values.add (tn);
Dropdown1.datasource = Values;
Dropdown1.databind ();
You can choose these two methods. I personally think that the latter method is more practical, especially when the data obtained from the database is used as the drop -down box option.
9. Hyperlink: Super connection, but different from HTML's <A HREF> as a server -side control, Hyperlink, with two attributes of Text and Navigateurl, and can be defined by data binding. I list two type below two types. Below I list two types below two types. Definition method:
Method 1:
<ASP: Hyperlink ID = Hyperlink1 Navigateurl = "/Quickstart" runat = Server>
Go to Quickstart
</asp: Hyperlink>
Method two:
< %@ Import namespace = System.data %>
<html>
<script Language = C# Runat = Server>
void page_load (Object SRC, EventArgs E) {{
datatable dt = new datatable ();
dataarow drr;
dt.columns.add (New DataColumn (IntegerValue, Typeof (Int32)));
dt.columns.add (New DataColumn (StringValue, Typeof (String));
dt.columns.add (New DataColumn (DatetimeValue, Typeof (Datetime)));
dt.columns.add (New DataColumn (BOOLVALUE, Typeof (Bool));
dt.columns.add (New DataColumn (CurrencyValue, Typeof (Double));
for (int i = 0; i <9; i ++) {
DR = dt.newrow ();
DR [0] = i;
DR [1] = item + int32.tostring (i);
DR [2] = dates.now;
DR [3] = (i % 2! = 0)? true: false;
DR [4] = 1.23 * (i+1);
DT.ROWS.ADD (DR);
}
myreper.datasource = New DataView (DT);
myreper.databind ();
}
</script>
<body>
<h3> <font face = Verdana> databinding htmlanchor </font> </h3>
<p>
<FORM RUNAT = Server>
<ASP: Repeater ID = MyRepeater Runat = Server>
<template name = itemtemplate>
link for
<ASP: Hyperlink ID = Hyperlink1 Text = '<%# DataBinder.eval.eval (container.dataItem, Stringvalue)%>' Navigateurl = '<%# , StringValue, DetailSpage.aspx? ID = {0 }) %> 'Runat = Server />
<p>
</template>
</asp: Repeater>
</form>
</body>
</html>
10. Image: Picture, there is only one attribute imageurl. Now you can change the picture in real time. I will not give it.
11. MAGEBUTTON: The picture button is better to understand, but you don't underestimate it. Compared with the picture button in DHTML, its function is much stronger. First of all, it can be used as a button (nonsense). Compared with this basic function, the function you want to talk about will make you staggering. It can judge the relative coordinates you click. What, it is useless? I. Essence I flatte you! Take a look at the following program:
ImageButton2.aspx
<html>
<head>
<script Language = C# Runat = Server>
void ImageButton1_ONCLICK (Object Source, ImageClickeventargs E) {{
int x = ex;
int y = ey;
label1.text = x: + x.tostring ();
label2.text = y: + y.tostring ();
Button1.imageURL = /QUICKSTART/aspplus/images/billg.gif;
// Check to see if if an eye, ear, nose or mott was cricked.
if (x> 20 && x <35 && y> 72 && y <88) {
label3.text = You click Bill's Ear.;
}
else if (x> 42 && x <58 && y> 48 && y <64) {{
label3.Text = You Clived Bill's Eye.;
}
else if (x> 62 && x <90) {
if (y> 46 && y <56) {
label3.Text = You Clived Bill's Eye.;
}
else if (y <72 && y> 60) {
label3.text = you click bill's nose.;
}
else if (y <92 && y> 74) {
Button1.imageURL = /QUICKSTART/aspplus/images/billg_tongue.gif;
label3.text = phfttttttttttt!.;
}
else {
whops ();
}
}
Else if (x> 100 && x <108 && y> 56 && y <72) {
label3.text = You click Bill's Ear.;
}
else {
whops ();
}
}
void whoops () {
Label3.Text = You Missed! Try Clicking Bill's Ears, Ears, Nose or Mouth.;
}
</script>
</head>
<body>
<h3> <font face = Verdana> USING ImageButton as an Image Map </font> </h3>
<FORM RUNAT = Server>
<Table width = 100% border = 0>
<tr>
<td width = 25%>
<Asp: ImageButton ID = Button1 ImageURL =/Quickstart/Aspplus/Images/Billg.gif BorderWidth = 2px Onclick = ImageButton1_onClick Runat = Server/>
</td>
<TD>
<asp: label id = label1 text = x: runat = server/>
<br>
<asp: label id = label2 text = y: runat = server/>
</td>
</tr>
</table>
<asp: label id = label3 font-black = true text = runat = server/>
</form>
</body>
</html>
Run, what do you see? It is Bill Gates a silly smile. If you order his eyes and nose, you will tell you where you are in the middle. If you click his mouth, he will stretch his tongue. Just judge the corresponding operations based on the relative position in your mouse point, but don't forget that this is just a simplicity function that can be done by a simple ImageButton.
12. Label, the previous example has been mentioned, it is a server -side text control. It has only one attribute: text, you can dynamically change it.
13. LinkButton: There is a server -side button control. Its external image Hyperlink has the same attributes, but the difference is that it can submit the form, the same as the other two Button control.
14. Listbox, list box. It is the same as the drop -down box. There are two ways to define options. One is a direct list and the other is data binding. I won't go into details.
15. Panel: Panel server -side control, this is a good thing. It can be used as a collection of other server -side control. The most practical place is to generate a set of server -side controls or display/hide a set of server -side controls. Look at it to see Is the following example, is it wonderful?
panel1.aspx
<html>
<head>
<script Language = C# Runat = Server>
void page_load (Object Sender, EventArgs E) {{
// Show/Hide Panel Contents
ifCK1.Checked) {
panel1.visible = false;
}
else {
panel1.visible = TRUE;
}
// Generate Label Controls
int NumLabels = int.fromstring (Dropdown1.SelectEditem.Value);
for (int i = 1; i <= numlabels; i ++) {
label l = new label ();
l.Text = label + int32.tostring (i);
l.id = label + int32.tostring (i);
Panel1.Controls.add (L);
Panel1.Controls.add (New LiteralControl (<br>));
}
// Generate Textbox Controls
int Numtexts = int.fromString (Dropdown2.SelectEdItem.Value);
for (int i = 1; i <= numtexts; i ++) {
textbox t = new textbox ();
T.Text = Textbox + int32.TOSTRING (i);
t.id = textbox + int32.tostring (i);
Panel1.Controls.add (T);
Panel1.Controls.add (New LiteralControl (<br>));
}
}
</script>
</head>
<body>
<h3> <font face = Verdana> Panel Example </font> </h3>
<FORM RUNAT = Server>
<ASP: Panel ID = Panel1 Runat = Server
backColor = GAINSBORO
height = 200px
width = 300px>
Panel1: Here is some static content ...
<p>
</asp: Panel>
<p>
Generate Labels:
<ASP: DropdownList ID = Dropdown1 Runat = Server>
<ASP: listitem value = 0> 0 </asp: listitem>
<Asp: listitem value = 1> 1 </asp: listitem>
<ASP: listitem value = 2> 2 </asp: listitem>
<ASP: listitem value = 3> 3 </asp: listitem>
<ASP: listitem value = 4> 4 </asp: listitem>
</asp: DropdownList>
<br>
Generate Textboxes:
<ASP: DropdownList ID = Dropdown2 Runat = Server>
<ASP: listitem value = 0> 0 </asp: listitem>
<Asp: listitem value = 1> 1 </asp: listitem>
<ASP: listitem value = 2> 2 </asp: listitem>
<ASP: listitem value = 3> 3 </asp: listitem>
<ASP: listitem value = 4> 4 </asp: listitem>
</asp: DropdownList>
<p>
<ASP: Checkbox ID = Check1 Text = Hide Panel Runat = Server/>
<p>
<ASP: Button Text = Refresh Panel Runat = Server/>
</font>
</form>
</body>
</html>
Okay, let's talk about it first, it's a bit tired. In the future, I will introduce the remaining 13 server -side control.