DoboWiki
Top
> .NETプログラミング研究/81 をテンプレートにして作成
.NETプログラミング研究/81 をテンプレートにして作成
開始行:
#title(Microsoft ASP.NET AJAXを使う2)
#navi(.NETプログラミング研究)
#contents
*Microsoft ASP.NET AJAXを使う2 [#x8be42c5]
[[前回>../80]]はUpdatePanelコントロールの基本的な使い方に...
**複数のUpdatePanelがある時に特定のUpdatePanelだけが更新...
まずは、一つのページにUpdatePanelを複数配置した時にどのよ...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanelテスト</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" T...
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="Button2" runat="server" T...
OnClick="Button2_Click" />
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanelテスト</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" T...
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="Button2" runat="server" T...
OnClick="Button2_Click" />
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
このサンプルでは、Button1をクリックしても、Button2をクリ...
しかし、あるトリガーでは、あるUpdatePanelしか更新しない(...
関連付けられたトリガーだけがそのUpdatePanelを更新できるよ...
実際に上記のサンプルのUpdatePanel1のUpdateModeプロパティ...
複数のUpdatePanelをページに配置した時は、UpdatePanelのUpd...
**プログラムでUpdatePanelを更新する [#g8083d8c]
プログラムでUpdatePanelを更新するには、UpdatePanelのUpdat...
#code(vbnet){{
Protected Sub Button2_Click(ByVal sender As Object, ByVal...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
'UpdatePanel1を更新する
UpdatePanel1.Update()
End Sub
}}
#code(csharp){{
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
//UpdatePanel1を更新する
UpdatePanel1.Update();
}
}}
**UpdatePanel内のコントローラによってそのUpdatePanelが更...
今で紹介してきた例では、UpdatePanel内にあるコントロールに...
ChildrenAsTriggersプロパティをFalseにするならば、UpdateMo...
ChildrenAsTriggersプロパティの動作について、具体例を見て...
[[ドキュメントによると>http://asp.net/ajax/documentation/...
**入れ子になったUpdatePanel [#t17e3cec]
ChildrenAsTriggersプロパティがTrueならば、そのUpdatePanel...
例えば以下のような例では、子のUpdatePanel2内にあるButton2...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<!-- 親UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="親更新"...
<asp:Label ID="Label1" runat="server"></a...
<br />
<!-- 子UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel2" runat=...
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button2" runat="s...
Text="子更新" OnClick="Button...
<asp:Label ID="Label2" runat="ser...
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<!-- 親UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="親更新"...
<asp:Label ID="Label1" runat="server"></a...
<br />
<!-- 子UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel2" runat=...
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button2" runat="s...
Text="子更新" OnClick="Button...
<asp:Label ID="Label2" runat="ser...
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
親のUpdatePanelが更新されれば、子のUpdatePanelも更新され...
**UpdatePanelに関連付けられていないコントロールで非同期ポ...
UpdatePanelの中にあるコントロールやUpdatePanelのTriggers...
これらの方法以外でScriptManagerに非同期ポストバックコント...
以下の例では、UpdatePanelの外にあるButton1を非同期ポスト...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal...
'Button1を非同期ポストバックコントロールとして登...
ScriptManager1.RegisterAsyncPostBackControl(Butto...
End Sub
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
'UpdatePanel2を更新する
UpdatePanel2.Update()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="更新"
OnClick="Button1_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Button1を非同期ポストバックコントロールとして登...
ScriptManager1.RegisterAsyncPostBackControl(Butto...
}
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
//UpdatePanel2を更新する
UpdatePanel2.Update();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="更新"
OnClick="Button1_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
**コメント [#qc92bfdf]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2007-1...
終了行:
#title(Microsoft ASP.NET AJAXを使う2)
#navi(.NETプログラミング研究)
#contents
*Microsoft ASP.NET AJAXを使う2 [#x8be42c5]
[[前回>../80]]はUpdatePanelコントロールの基本的な使い方に...
**複数のUpdatePanelがある時に特定のUpdatePanelだけが更新...
まずは、一つのページにUpdatePanelを複数配置した時にどのよ...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanelテスト</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" T...
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="Button2" runat="server" T...
OnClick="Button2_Click" />
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>UpdatePanelテスト</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" T...
OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Button ID="Button2" runat="server" T...
OnClick="Button2_Click" />
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
このサンプルでは、Button1をクリックしても、Button2をクリ...
しかし、あるトリガーでは、あるUpdatePanelしか更新しない(...
関連付けられたトリガーだけがそのUpdatePanelを更新できるよ...
実際に上記のサンプルのUpdatePanel1のUpdateModeプロパティ...
複数のUpdatePanelをページに配置した時は、UpdatePanelのUpd...
**プログラムでUpdatePanelを更新する [#g8083d8c]
プログラムでUpdatePanelを更新するには、UpdatePanelのUpdat...
#code(vbnet){{
Protected Sub Button2_Click(ByVal sender As Object, ByVal...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
'UpdatePanel1を更新する
UpdatePanel1.Update()
End Sub
}}
#code(csharp){{
protected void Button2_Click(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
//UpdatePanel1を更新する
UpdatePanel1.Update();
}
}}
**UpdatePanel内のコントローラによってそのUpdatePanelが更...
今で紹介してきた例では、UpdatePanel内にあるコントロールに...
ChildrenAsTriggersプロパティをFalseにするならば、UpdateMo...
ChildrenAsTriggersプロパティの動作について、具体例を見て...
[[ドキュメントによると>http://asp.net/ajax/documentation/...
**入れ子になったUpdatePanel [#t17e3cec]
ChildrenAsTriggersプロパティがTrueならば、そのUpdatePanel...
例えば以下のような例では、子のUpdatePanel2内にあるButton2...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<!-- 親UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="親更新"...
<asp:Label ID="Label1" runat="server"></a...
<br />
<!-- 子UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel2" runat=...
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button2" runat="s...
Text="子更新" OnClick="Button...
<asp:Label ID="Label2" runat="ser...
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
protected void Button2_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<!-- 親UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel1" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Text="親更新"...
<asp:Label ID="Label1" runat="server"></a...
<br />
<!-- 子UpdatePanel -->
<asp:UpdatePanel ID="UpdatePanel2" runat=...
UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button2" runat="s...
Text="子更新" OnClick="Button...
<asp:Label ID="Label2" runat="ser...
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
親のUpdatePanelが更新されれば、子のUpdatePanelも更新され...
**UpdatePanelに関連付けられていないコントロールで非同期ポ...
UpdatePanelの中にあるコントロールやUpdatePanelのTriggers...
これらの方法以外でScriptManagerに非同期ポストバックコント...
以下の例では、UpdatePanelの外にあるButton1を非同期ポスト...
#code(vbnet){{
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal...
'Button1を非同期ポストバックコントロールとして登...
ScriptManager1.RegisterAsyncPostBackControl(Butto...
End Sub
Protected Sub Button1_Click(ByVal sender As Object, B...
Label1.Text = DateTime.Now.ToString()
Label2.Text = DateTime.Now.ToString()
'UpdatePanel2を更新する
UpdatePanel2.Update()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="更新"
OnClick="Button1_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
#code(csharp){{
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional...
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Button1を非同期ポストバックコントロールとして登...
ScriptManager1.RegisterAsyncPostBackControl(Butto...
}
protected void Button1_Click(object sender, EventArgs...
{
Label1.Text = DateTime.Now.ToString();
Label2.Text = DateTime.Now.ToString();
//UpdatePanel2を更新する
UpdatePanel2.Update();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="更新"
OnClick="Button1_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Label2" runat="server"></a...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
**コメント [#qc92bfdf]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2007-1...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]