62,046
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Web.UI.WebControls;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
// 更新GridView方法
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = this.DropDownList1.SelectedIndex;
string textValue = "你选择了DropDownList1的Index是:" + selectedIndex;
ListItem item = new ListItem(textValue);
if (!DropDownList2.Items.Contains(item))
{
DropDownList2.Items.Add(item);
}
DropDownList2.Text = textValue;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>请选择...</asp:ListItem>
<asp:ListItem>祖国</asp:ListItem>
<asp:ListItem>万岁</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button" runat="server" Text="Button" onclick="Button_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Page_Load() {
if (!IsPostBack) {
}
}
<%@ Register Assembly="Microsoft.Web.Atlas" Namespace="Microsoft.Web.UI" TagPrefix="cc1" %>
<cc1:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</cc1:ScriptManager>
<asp:DropDownList ID="aaa" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlthumbnail_SelectedIndexChanged">
</asp:DropDownList>
<cc1:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblatnail" runat="server" Text="" Visible=false></asp:Label>
<asp:LinkButton ID="lbtnatnail" runat="server" Visible=false>View</asp:LinkButton><br />
</ContentTemplate>
<Triggers>
<cc1:ControlEventTrigger ControlID="aaa" EventName="SelectedIndexChanged"></cc1:ControlEventTrigger>
</Triggers>
</cc1:UpdatePanel>