正 文

ASP.net(VB)编程入门进阶 Ⅰ


www.7dspace.com  更新日期:2005-10-15 5:45:20  七度空间


另外,再看看<asp:Dropdownlist>控件吧。启动webmatrix,创建一个新文件p56.aspx,选择design视图,然后在左边选择dropdownlist控件:

把它选中用鼠标拉到界面上,就像DM里面一样的.单击,然后在右边选择:

Items,它控制的是下拉选项项目,点击最右边的几个小点点..

弹出的对话框中选add,在写上选项名称id,value,点击Ok。
同理添加一个submit按钮,在properties里面设置一下背景,边框呀什么的,然后启动状态栏中间的箭头按钮在浏览器中看看,效果:

是不是很酷?不急,还没有完,选all视图,在<script runat="server">:

<script runat="server">
   
    sub page_load()
   
   
    if page.ispostback then
    message.text="you choice the web site of:"+dropdownlist1.selecteditem.value
    end if
   
    end sub

下面添加一个sub事件相应按钮选项,如果页面已经提交ispostback就返回true,否则返回false。当然也要添加一个label,id命名为message,okok,现在看看效果:

嗯,它就是这样相应的,看看所有的这个源码:

<%@ Page Language="VB" %>
<script runat="server">
    ' Insert page code here
    sub page_load()
    if page.ispostback then
    message.text="you choice the web site of:"+dropdownlist1.selecteditem.value
    end if
    end sub
    Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
    End Sub
</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:DropDownList id="DropDownList1" runat="server" BackColor="Control" ForeColor="#400000" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                <asp:ListItem Value="blueidea">blueidea</asp:ListItem>
                <asp:ListItem Value="tillage village">tillage village</asp:ListItem>
                <asp:ListItem Value="warra">warra</asp:ListItem>
                <asp:ListItem Value="leadbbs">leadbbs</asp:ListItem>
                <asp:ListItem Value="vv32">vv32</asp:ListItem>
                <asp:ListItem Value="web site">web site</asp:ListItem>
            </asp:DropDownList>
            <asp:Button id="Button1" runat="server" BackColor="#E0E0E0" ForeColor="Maroon" Text="submit query" BorderColor="DarkCyan" BorderStyle="Double"></asp:Button>
        </p>
        <p>
            <asp:Label id="message" runat="server" Width="370px" Height="28px"></asp:Label>
        </p>
    </form>
</body>
</html>

4页,页码:[1] [2] [3] [4] 

上一篇:XMLBean 引领 XML 走向未来
下一篇:基于java的图片文件格式转换和线性缩放
作者:5do8  来源:蓝色理想 ( 责任编辑:7dspace )
收藏此页】【打印】【关闭
站 内 搜 索
 

热 点 导 读
特 别 推 荐