Skip to content

Instantly share code, notes, and snippets.

@masaru-b-cl
Created June 22, 2012 17:04
Show Gist options
  • Save masaru-b-cl/2973994 to your computer and use it in GitHub Desktop.
Save masaru-b-cl/2973994 to your computer and use it in GitHub Desktop.
ViewState無効時のSelectedIndexChangedイベントの挙動確認
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = "SelectedIndexChanged!";
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = "SelectedIndexChanged!";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h3>
ViewStateMode=Enabled
</h3>
<div>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
ViewStateMode="Enabled">
<asp:ListItem Text="C#" Value="1" />
<asp:ListItem Text="F#" Value="2" />
<asp:ListItem Text="VB" Value="3" />
</asp:DropDownList>
</div>
<p>
<asp:Label ID="Label1" runat="server" Text="" ViewStateMode="Disabled"></asp:Label>
</p>
<h3>
ViewStateMode=Disabled
</h3>
<div>
<asp:DropDownList ID="DropDownList2" runat="server" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"
ViewStateMode="Disabled">
<asp:ListItem Text="C#" Value="1" />
<asp:ListItem Text="F#" Value="2" />
<asp:ListItem Text="VB" Value="3" />
</asp:DropDownList>
</div>
<p>
<asp:Label ID="Label2" runat="server" Text="" ViewStateMode="Disabled"></asp:Label>
</p>
<asp:Button ID="Button2" runat="server" Text="Button" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment