我如何在asp.net中执行以下操作?

时间:2013-05-27 10:32:16

标签: asp.net ajax

我正在尝试在asp.net中创建一个简单的课程注册网站。我现在正在创建一个允许用户创建课程的页面。以下是相关的用户界面:

enter image description here

以下是此页面的代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdminCreateCourse.aspx.cs"
Inherits="AdminCreateCourse" %>

<!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></title>
<style type="text/css">
    .style1
    {
        font-size: x-large;
    }
    .style3
    {
        font-size: small;
    }
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="style1">
    <strong>Create Course</strong></div>
<p>
    &nbsp;</p>
<p>
    Instructor Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:DropDownList ID="dInstructorSelect" runat="server" DataSourceID="SqlDataSource1"
        DataTextField="FullName" DataValueField="FullName" Height="16px" Width="202px">
    </asp:DropDownList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

        SelectCommand="SELECT [Name] + ' ' + [Surname] as FullName FROM [InstructorTable] ORDER BY [Name]">
    </asp:SqlDataSource>
</p>
<p>
    Course Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tCourseName" runat="server"></asp:TextBox>
</p>
<p>
    Course ID<br />
    (Subject/Course):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:DropDownList ID="dSubject" runat="server" Width="70px">
        <asp:ListItem>CS</asp:ListItem>
        <asp:ListItem>CULT</asp:ListItem>
        <asp:ListItem>ECON</asp:ListItem>
        <asp:ListItem>IS</asp:ListItem>
        <asp:ListItem>MAN</asp:ListItem>
        <asp:ListItem>SPS</asp:ListItem>
        <asp:ListItem>VACD</asp:ListItem>
        <asp:ListItem>BIO</asp:ListItem>
        <asp:ListItem>EE</asp:ListItem>
        <asp:ListItem>EL</asp:ListItem>
        <asp:ListItem>MAT</asp:ListItem>
        <asp:ListItem>ME</asp:ListItem>
        <asp:ListItem>MS</asp:ListItem>
        <asp:ListItem>TE</asp:ListItem>
    </asp:DropDownList>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tCourse" runat="server" Width="70px"></asp:TextBox>
</p>
<p>
    CRN:&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:TextBox ID="tCRN" runat="server"></asp:TextBox>
</p>
<p>
    Level:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:DropDownList ID="dLevel" runat="server">
        <asp:ListItem>Undergraduate</asp:ListItem>
        <asp:ListItem>Graduate</asp:ListItem>
    </asp:DropDownList>
</p>
<p>
    Term:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</p>
<p>
    Course Description:
</p>
<p>
    &nbsp;<asp:TextBox ID="tCourseDescription" runat="server" Height="138px" Width="406px"></asp:TextBox>
</p>
<p>
    Capacity:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tCapacity" runat="server"></asp:TextBox>
</p>
<p>
    Class Hour and Day: <span class="style3">Start Hour:
        <asp:DropDownList ID="dHourStart" runat="server">
            <asp:ListItem>8:40</asp:ListItem>
            <asp:ListItem>9:40</asp:ListItem>
            <asp:ListItem>10:40</asp:ListItem>
            <asp:ListItem>11:40</asp:ListItem>
            <asp:ListItem>12:40</asp:ListItem>
            <asp:ListItem>13:40</asp:ListItem>
            <asp:ListItem>14:40</asp:ListItem>
            <asp:ListItem>15:40</asp:ListItem>
            <asp:ListItem>16:40</asp:ListItem>
            <asp:ListItem>17:40</asp:ListItem>
            <asp:ListItem>18:40</asp:ListItem>
            <asp:ListItem>19:40</asp:ListItem>
        </asp:DropDownList>
        &nbsp; End Hour:
        <asp:DropDownList ID="dHourEnd" runat="server">
            <asp:ListItem>10:30</asp:ListItem>
            <asp:ListItem>11:30</asp:ListItem>
            <asp:ListItem>12:30</asp:ListItem>
            <asp:ListItem>13:30</asp:ListItem>
            <asp:ListItem>14:30</asp:ListItem>
            <asp:ListItem>15:30</asp:ListItem>
            <asp:ListItem>16:30</asp:ListItem>
            <asp:ListItem>17:30</asp:ListItem>
            <asp:ListItem>18:30</asp:ListItem>
            <asp:ListItem>19:30</asp:ListItem>
            <asp:ListItem>20:30</asp:ListItem>
            <asp:ListItem>9:30</asp:ListItem>
        </asp:DropDownList>
        &nbsp; Day:</span> &nbsp;<asp:DropDownList ID="dDay" runat="server">
            <asp:ListItem>Monday</asp:ListItem>
            <asp:ListItem>Tuesday</asp:ListItem>
            <asp:ListItem>Wednesday</asp:ListItem>
            <asp:ListItem>Thursday</asp:ListItem>
            <asp:ListItem>Friday</asp:ListItem>
        </asp:DropDownList>
    &nbsp;&nbsp;
    <asp:Button ID="bAddCourseHour" runat="server" Text="Add" OnClick="bAddCourseHour_Click" />
</p>
<p>
    Prerequisites:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tPreq1" runat="server" Width="100px"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tPreq2" runat="server" Width="100px"></asp:TextBox>
    &nbsp;&nbsp;&nbsp;
    <asp:TextBox ID="tPreq3" runat="server" Width="100px"></asp:TextBox>
</p>
<asp:Button ID="bSubmit" runat="server" Text="Submit" OnClick="bSubmit_Click" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<asp:Button ID="bClear" runat="server" Text="Clear" OnClick="bClear_Click" />
</form>
</body>
</html>

我的问题是,课程可能会在不止一天内举行,但我的界面只允许一天。我应该使用AJAX处理这个问题,还是有其他办法吗?如果我应该使用ajax,我该怎么做?

由于

1 个答案:

答案 0 :(得分:1)

我假设您正在寻找一种允许在“日”字段中进行多项选择的方法。如果是这样,你至少有几个选择:

1)使用CheckBoxList控件(http://msdn.microsoft.com/enIN/library/8bw4x4wa(v=vs.90).aspx)。 2)或者,如果房地产是个问题,请使用http://dropdowncheckboxes.codeplex.com/处的DropDownCheckBoxes控件