ASP.NET 初始入门

                                                                            用户注册页面     

  为了网络中心的招聘,开始学习asp.net了,和前面学的网页制作完全两个概念,感觉自己悟性还是有点弱(笨?)

       几天为网络中心第三次考核第一天,十五天小组开发个网站,全部都是用新知识开发,昨晚布置了一晚开发工具,见天看了一天asp.net,,从下午开始上机写代码,到现在,第一个程序基本理解了,路漫漫其修远兮,任重道远,努力!

       进程有点慢,希望以后可以快点,我在这次项目分工里为数据库设计,看似简单实则不易,并且是整个项目的核心,我会好好完成的。

       纪念第一次的接触.net,发表见天做的注册页面如下:


前台代码:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4.WebForm1" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>changxing
    </title>
    <link href="/style/site.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        #Radio2
        {
            width: 19px;
        }
    </style>
   
</head>
<body  >
    <form id="form1" runat="server">
    <div id = "header">
    
        &nbsp;&nbsp;&nbsp 
        用户注册</div>
    <div>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        我的第一个asp.net网页</div>
    <p>
&nbsp;&nbsp;&nbsp;&nbsp; 用户名: 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </p>
    <p>
&nbsp;&nbsp;&nbsp;&nbsp; 密 码 :<asp:TextBox 
            ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
    </p>
    <asp:Panel ID="Panel1" runat="server" Width="1018px">
        &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 性别:<asp:RadioButton ID="RadioButton2" runat="server" 
            GroupName="sexy" Text="男" />
        &nbsp;<asp:RadioButton ID="RadioButton3" runat="server" GroupName="sexy" Text="女" />
        &nbsp;<asp:Panel ID="Panel2" runat="server" style="margin-top: 0px" Width="1016px">
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 职业:<asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                AutoPostBack="True" BorderStyle="Solid" RepeatLayout="Flow" Width="266px">
                <asp:ListItem>老师</asp:ListItem>
                <asp:ListItem>医生</asp:ListItem>
                <asp:ListItem Selected="True">程序员</asp:ListItem>
            </asp:RadioButtonList>
            <br />
        </asp:Panel>
    </asp:Panel>
    <p>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所属省份:<asp:DropDownList 
            ID="DropDownList1" runat="server" AutoPostBack="True" BackColor="Yellow" 
            ForeColor="Blue" Height="29px" style="margin-left: 0px" Width="124px" 
            onselectedindexchanged="DropDownList1_SelectedIndexChanged">
             <asp:ListItem>北京</asp:ListItem>                           
              <asp:ListItem>河南省</asp:ListItem>                                                                                //asp中大部分的添加方法如,checkbox ,checkboxlist等
               <asp:ListItem>山东省</asp:ListItem>
                
            
        </asp:DropDownList>
        
    </p>
    <p>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 所在城市:&nbsp;<asp:ListBox 
            ID="ListBox1" runat="server" Height="61px" style="margin-top: 10px" 
            Width="206px"></asp:ListBox>
    </p>
    <p>
       


    </p>
    <p>
          
    </p>
    <p>
        <asp:Button 
            ID="Button2" runat="server" οnclick="Button2_Click" Text="Button" />
        &nbsp; 
        &nbsp;&nbsp;
        <input id="Reset1" type="reset" value="reset" /></p>
    <p>
        &nbsp;</p>
    </form>
</body>
</html>

后台代码(c#):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;


namespace WebApplication4
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        public WebForm1()
        {
   
          
        }


        protected void Page_Load(object sender, EventArgs e)
        {


        }


        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (DropDownList1.SelectedItem.Text)
            {
                case "河南省": 
                    ListBox1.Items.Clear();
                    ListBox1.Items.Add("林州");
                    ListBox1.Items.Add("开封");
                    break;
                case "北京":
                    ListBox1.Items.Clear();
                    ListBox1.Items.Add("天俺们");
                    ListBox1.Items.Add("长城");
                    break;
                case "浙江":
                    ListBox1.Items.Clear();
                    ListBox1.Items.Add("青岛");
                    ListBox1.Items.Add("济南");
                    break;
            }




        }


        protected void Button2_Click(object sender, EventArgs e)
        {
            string name, password, sex, work, location = "";
            if (TextBox1.Text == "")
            {
                Response.Write("<script>window.alert('用户名不能空!');</script>");
            }
            else
            {
                name = TextBox1.Text;
                password = TextBox2.Text;
                if (RadioButton2.Checked)
                {
                    sex = "男";
                }
                else
                {
                    sex = "女";
                }
                work = RadioButtonList1.SelectedItem.Text;
                if (ListBox1.SelectedItem != null)
                {
                    location = DropDownList1.SelectedItem.Text + "," + ListBox1.SelectedItem.Text;
                }
                
              
                Response.Redirect(string.Format("simpleresult.aspx?name={0}&sex={1}&work={2}&location={3}&password={4}",name,sex,work,location,password));  //不能空格
            }
   
        }

    }
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值