ASP.NET서버컨트롤, asp:dropdownlist[C#, ASP.NET강좌]
꽁스짱
ASP.NET
0
1045
2021.02.17 01:39
ASP.NET서버컨트롤, asp:dropdownlist[C#, ASP.NET강좌]
HTML에서 <select>와 <option> 태그를 사용하는 것이다.
<select> 대신 <asp:dropdownlist> 태그가 사용
<option> 대신 <asp:listitem> 태그가 사용
Name 속성 대신 id 속성 사용
(onj5.aspx)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="onj5.aspx.cs" Inherits="onjweb1.onj5" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<asp:label id="msg" runat="server"/><br/><br/>
<form id="form1" runat="server">
좋아하는과목선택하세요~ <br/><br/>
<asp:dropdownlist id="list1" runat="server">
<asp:listitem>오라클</asp:listitem>
<asp:listitem selected>닷넷</asp:listitem>
<asp:listitem>자바</asp:listitem>
</asp:dropdownlist>
<br/><br/>
<input type="submit">
</form>
</body>
</html>
(onj5.aspx.cs)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace onjweb1
{
public partial class onj5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["list1"] != null)
{
msg.Text = Request.Form["list1"];
}
}
}
}
{
public partial class onj5 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["list1"] != null)
{
msg.Text = Request.Form["list1"];
}
}
}
}