DoboWiki
Top
> .NETプログラミング研究/80 をテンプレートにして作成
.NETプログラミング研究/80 をテンプレートにして作成
開始行:
#title(Microsoft ASP.NET AJAXを使う)
#navi(.NETプログラミング研究)
#contents
*Microsoft ASP.NET AJAXを使う [#d37ae965]
ASP.NETでAjaxを使ったWebアプリケーションを作成する方法を...
ここで紹介する[[Microsoft ASP.NET AJAX>http://asp.net/aja...
ASP.NET AJAXはマイクロソフトが公開している無料のフレーム...
**ASP.NET AJAXをインストールする [#z541599a]
ASP.NET AJAXをインストールするには.NET Framework 2.0が必...
ASP.NET AJAXは「[[ASP.NET AJAX Downloads : The Official M...
ダウンロードされたファイルは、"ASPAJAXExtSetup.msi"のよう...
ASP.NET AJAXのインストールに成功すると、Visual Studio 200...
&ref(selecttemplate.png,nolink,ASP.NET AJAX-Enabled Web S...
&ref(toolbox.png,nolink,ツールボックスの「AJAX Extensions...
ASP.NET AJAXを使用するには、Web.configに適切な設定が必要...
テンプレート「ASP.NET AJAX-Enabled Web Site」を使わなかっ...
Visual Studioをインストールしていない場合は、Web.configの...
**UpdatePanelを使う [#updatepanel]
早速ASP.NET AJAXを使ってみましょう。ここでは、前回、前々...
Visual Studioを使用した場合の手順は、次のようになります。
+メニューの[ファイル]-[新規作成]-[Webサイト]から、「ASP.N...
+Default.aspxのデザインを開きます。ScriptManagerコントロ...
+ツールボックスの「AJAX Extensions」タブからUpdatePanelを...
+前々号の「[[Ajaxを使用しない方法>../78#noajax]]」で紹介...
&ref(updatepanel.png,nolink,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 PackageSizeList_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = CType(sender, DropDownL...
If ddl.SelectedValue <> "0" Then
Dim fee As Integer = _
Me.GetYoupackFee(Integer.Parse(ddl.Select...
ResultLabel.Text = String.Format("料金は {0}...
Else
ResultLabel.Text = ""
End If
End Sub
Public Function GetYoupackFee(ByVal packSize As Integ...
If packSize <= 60 Then
Return 600
ElseIf packSize <= 80 Then
Return 800
ElseIf packSize <= 100 Then
Return 1000
ElseIf packSize <= 120 Then
Return 1200
ElseIf packSize <= 140 Then
Return 1400
ElseIf packSize <= 160 Then
Return 1600
ElseIf packSize <= 170 Then
Return 1700
Else
Return -1
End If
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合...
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeLi...
<asp:ListItem Value="0">(選択してく...
<asp:ListItem Value="60">60cmまで</as...
<asp:ListItem Value="80">80cmまで</as...
<asp:ListItem Value="100">100cmまで</...
<asp:ListItem Value="120">120cmまで</...
<asp:ListItem Value="140">140cmまで</...
<asp:ListItem Value="160">160cmまで</...
<asp:ListItem Value="170">170cmまで</...
</asp:DropDownList>
<br />
<asp:Label ID="ResultLabel" runat="server...
</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 PackageSizeList_SelectedIndexChanged(
object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
if (ddl.SelectedValue != "0")
{
int fee = this.GetYoupackFee(int.Parse(ddl.Se...
ResultLabel.Text = string.Format("料金は {0}...
}
else
{
ResultLabel.Text = "";
}
}
public int GetYoupackFee(int packSize)
{
if (packSize <= 60)
return 600;
else if (packSize <= 80)
return 800;
else if (packSize <= 100)
return 1000;
else if (packSize <= 120)
return 1200;
else if (packSize <= 140)
return 1400;
else if (packSize <= 160)
return 1600;
else if (packSize <= 170)
return 1700;
else
return -1;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合...
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeLi...
<asp:ListItem Value="0">(選択してく...
<asp:ListItem Value="60">60cmまで</as...
<asp:ListItem Value="80">80cmまで</as...
<asp:ListItem Value="100">100cmまで</...
<asp:ListItem Value="120">120cmまで</...
<asp:ListItem Value="140">140cmまで</...
<asp:ListItem Value="160">160cmまで</...
<asp:ListItem Value="170">170cmまで</...
</asp:DropDownList>
<br />
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
以上ですべて終了です。
驚くことに、前々回紹介した、Ajaxを使用せずに、今までどお...
UpdatePanelコントロールを使うためには、ScriptManagerコン...
補足:UpdatePanelコントロールの部分に出力されるHTMLは、<d...
**トリガーをUpdatePanelの外に出す [#triggers]
上記の例では全てのコントロールをUpdatePanelコントロール内...
UpdatePanelコントロールの中身を更新するためのきっかけとな...
実際に上記のコードを改造してみましょう。
+"Label1"と"PackageSizeList"をUpdatePanelの外に出します。
+デザイナで"UpdatePanel1"を選択し、プロパティウィンドウの...
+「追加」ボタンをクリックして、「メンバ」に「AsyncPostBac...
+「ControlID」プロパティを"PackageSizeList"とします。つま...
+「EventName」プロパティを"SelectedIndexChanged"とします...
&ref(triggers.png,nolink,UpdatePanelTriggerコレクションエ...
+「OK」ボタンをクリックします。
+以上です。
この改造によって出来上がったコードは、次のようになります。
#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 PackageSizeList_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = CType(sender, DropDownL...
If ddl.SelectedValue <> "0" Then
Dim fee As Integer = _
Me.GetYoupackFee(Integer.Parse(ddl.Select...
ResultLabel.Text = String.Format("料金は {0}...
Else
ResultLabel.Text = ""
End If
End Sub
Public Function GetYoupackFee(ByVal packSize As Integ...
If packSize <= 60 Then
Return 600
ElseIf packSize <= 80 Then
Return 800
ElseIf packSize <= 100 Then
Return 1000
ElseIf packSize <= 120 Then
Return 1200
ElseIf packSize <= 140 Then
Return 1400
ElseIf packSize <= 160 Then
Return 1600
ElseIf packSize <= 170 Then
Return 1700
Else
Return -1
End If
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合計): "
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeList_Selec...
<asp:ListItem Value="0">(選択してください)<...
<asp:ListItem Value="60">60cmまで</asp:ListIt...
<asp:ListItem Value="80">80cmまで</asp:ListIt...
<asp:ListItem Value="100">100cmまで</asp:List...
<asp:ListItem Value="120">120cmまで</asp:List...
<asp:ListItem Value="140">140cmまで</asp:List...
<asp:ListItem Value="160">160cmまで</asp:List...
<asp:ListItem Value="170">170cmまで</asp:List...
</asp:DropDownList>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Pack...
EventName="SelectedIndexChanged" />
</Triggers>
</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 PackageSizeList_SelectedIndexChanged(
object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
if (ddl.SelectedValue != "0")
{
int fee = this.GetYoupackFee(int.Parse(ddl.Se...
ResultLabel.Text = string.Format("料金は {0}...
}
else
{
ResultLabel.Text = "";
}
}
public int GetYoupackFee(int packSize)
{
if (packSize <= 60)
return 600;
else if (packSize <= 80)
return 800;
else if (packSize <= 100)
return 1000;
else if (packSize <= 120)
return 1200;
else if (packSize <= 140)
return 1400;
else if (packSize <= 160)
return 1600;
else if (packSize <= 170)
return 1700;
else
return -1;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合計): "
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeList_Selec...
<asp:ListItem Value="0">(選択してください)<...
<asp:ListItem Value="60">60cmまで</asp:ListIt...
<asp:ListItem Value="80">80cmまで</asp:ListIt...
<asp:ListItem Value="100">100cmまで</asp:List...
<asp:ListItem Value="120">120cmまで</asp:List...
<asp:ListItem Value="140">140cmまで</asp:List...
<asp:ListItem Value="160">160cmまで</asp:List...
<asp:ListItem Value="170">170cmまで</asp:List...
</asp:DropDownList>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Pack...
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
**UpdatePanelの制限 [#jbc89610]
このようにUpdatePanelは非常に簡単で、便利ですが、注意しな...
例えば、UpdatePanelの中に入れることのできないコントロール...
今回はこれでおしまいです。次回もASP.NET AJAXについて説明...
**参考 [#l5014b26]
-[[UpdatePanel Control Overview>http://asp.net/AJAX/Docum...
-[[UpdatePanel Control Tutorials>http://asp.net/AJAX/Docu...
-[[UpdatePanel Class>http://asp.net/AJAX/Documentation/Li...
**コメント [#t3c14c1b]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2007-1...
終了行:
#title(Microsoft ASP.NET AJAXを使う)
#navi(.NETプログラミング研究)
#contents
*Microsoft ASP.NET AJAXを使う [#d37ae965]
ASP.NETでAjaxを使ったWebアプリケーションを作成する方法を...
ここで紹介する[[Microsoft ASP.NET AJAX>http://asp.net/aja...
ASP.NET AJAXはマイクロソフトが公開している無料のフレーム...
**ASP.NET AJAXをインストールする [#z541599a]
ASP.NET AJAXをインストールするには.NET Framework 2.0が必...
ASP.NET AJAXは「[[ASP.NET AJAX Downloads : The Official M...
ダウンロードされたファイルは、"ASPAJAXExtSetup.msi"のよう...
ASP.NET AJAXのインストールに成功すると、Visual Studio 200...
&ref(selecttemplate.png,nolink,ASP.NET AJAX-Enabled Web S...
&ref(toolbox.png,nolink,ツールボックスの「AJAX Extensions...
ASP.NET AJAXを使用するには、Web.configに適切な設定が必要...
テンプレート「ASP.NET AJAX-Enabled Web Site」を使わなかっ...
Visual Studioをインストールしていない場合は、Web.configの...
**UpdatePanelを使う [#updatepanel]
早速ASP.NET AJAXを使ってみましょう。ここでは、前回、前々...
Visual Studioを使用した場合の手順は、次のようになります。
+メニューの[ファイル]-[新規作成]-[Webサイト]から、「ASP.N...
+Default.aspxのデザインを開きます。ScriptManagerコントロ...
+ツールボックスの「AJAX Extensions」タブからUpdatePanelを...
+前々号の「[[Ajaxを使用しない方法>../78#noajax]]」で紹介...
&ref(updatepanel.png,nolink,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 PackageSizeList_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = CType(sender, DropDownL...
If ddl.SelectedValue <> "0" Then
Dim fee As Integer = _
Me.GetYoupackFee(Integer.Parse(ddl.Select...
ResultLabel.Text = String.Format("料金は {0}...
Else
ResultLabel.Text = ""
End If
End Sub
Public Function GetYoupackFee(ByVal packSize As Integ...
If packSize <= 60 Then
Return 600
ElseIf packSize <= 80 Then
Return 800
ElseIf packSize <= 100 Then
Return 1000
ElseIf packSize <= 120 Then
Return 1200
ElseIf packSize <= 140 Then
Return 1400
ElseIf packSize <= 160 Then
Return 1600
ElseIf packSize <= 170 Then
Return 1700
Else
Return -1
End If
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合...
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeLi...
<asp:ListItem Value="0">(選択してく...
<asp:ListItem Value="60">60cmまで</as...
<asp:ListItem Value="80">80cmまで</as...
<asp:ListItem Value="100">100cmまで</...
<asp:ListItem Value="120">120cmまで</...
<asp:ListItem Value="140">140cmまで</...
<asp:ListItem Value="160">160cmまで</...
<asp:ListItem Value="170">170cmまで</...
</asp:DropDownList>
<br />
<asp:Label ID="ResultLabel" runat="server...
</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 PackageSizeList_SelectedIndexChanged(
object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
if (ddl.SelectedValue != "0")
{
int fee = this.GetYoupackFee(int.Parse(ddl.Se...
ResultLabel.Text = string.Format("料金は {0}...
}
else
{
ResultLabel.Text = "";
}
}
public int GetYoupackFee(int packSize)
{
if (packSize <= 60)
return 600;
else if (packSize <= 80)
return 800;
else if (packSize <= 100)
return 1000;
else if (packSize <= 120)
return 1200;
else if (packSize <= 140)
return 1400;
else if (packSize <= 160)
return 1600;
else if (packSize <= 170)
return 1700;
else
return -1;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合...
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeLi...
<asp:ListItem Value="0">(選択してく...
<asp:ListItem Value="60">60cmまで</as...
<asp:ListItem Value="80">80cmまで</as...
<asp:ListItem Value="100">100cmまで</...
<asp:ListItem Value="120">120cmまで</...
<asp:ListItem Value="140">140cmまで</...
<asp:ListItem Value="160">160cmまで</...
<asp:ListItem Value="170">170cmまで</...
</asp:DropDownList>
<br />
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
以上ですべて終了です。
驚くことに、前々回紹介した、Ajaxを使用せずに、今までどお...
UpdatePanelコントロールを使うためには、ScriptManagerコン...
補足:UpdatePanelコントロールの部分に出力されるHTMLは、<d...
**トリガーをUpdatePanelの外に出す [#triggers]
上記の例では全てのコントロールをUpdatePanelコントロール内...
UpdatePanelコントロールの中身を更新するためのきっかけとな...
実際に上記のコードを改造してみましょう。
+"Label1"と"PackageSizeList"をUpdatePanelの外に出します。
+デザイナで"UpdatePanel1"を選択し、プロパティウィンドウの...
+「追加」ボタンをクリックして、「メンバ」に「AsyncPostBac...
+「ControlID」プロパティを"PackageSizeList"とします。つま...
+「EventName」プロパティを"SelectedIndexChanged"とします...
&ref(triggers.png,nolink,UpdatePanelTriggerコレクションエ...
+「OK」ボタンをクリックします。
+以上です。
この改造によって出来上がったコードは、次のようになります。
#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 PackageSizeList_SelectedIndexChanged( _
ByVal sender As Object, ByVal e As EventArgs)
Dim ddl As DropDownList = CType(sender, DropDownL...
If ddl.SelectedValue <> "0" Then
Dim fee As Integer = _
Me.GetYoupackFee(Integer.Parse(ddl.Select...
ResultLabel.Text = String.Format("料金は {0}...
Else
ResultLabel.Text = ""
End If
End Sub
Public Function GetYoupackFee(ByVal packSize As Integ...
If packSize <= 60 Then
Return 600
ElseIf packSize <= 80 Then
Return 800
ElseIf packSize <= 100 Then
Return 1000
ElseIf packSize <= 120 Then
Return 1200
ElseIf packSize <= 140 Then
Return 1400
ElseIf packSize <= 160 Then
Return 1600
ElseIf packSize <= 170 Then
Return 1700
Else
Return -1
End If
End Function
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合計): "
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeList_Selec...
<asp:ListItem Value="0">(選択してください)<...
<asp:ListItem Value="60">60cmまで</asp:ListIt...
<asp:ListItem Value="80">80cmまで</asp:ListIt...
<asp:ListItem Value="100">100cmまで</asp:List...
<asp:ListItem Value="120">120cmまで</asp:List...
<asp:ListItem Value="140">140cmまで</asp:List...
<asp:ListItem Value="160">160cmまで</asp:List...
<asp:ListItem Value="170">170cmまで</asp:List...
</asp:DropDownList>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Pack...
EventName="SelectedIndexChanged" />
</Triggers>
</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 PackageSizeList_SelectedIndexChanged(
object sender, EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
if (ddl.SelectedValue != "0")
{
int fee = this.GetYoupackFee(int.Parse(ddl.Se...
ResultLabel.Text = string.Format("料金は {0}...
}
else
{
ResultLabel.Text = "";
}
}
public int GetYoupackFee(int packSize)
{
if (packSize <= 60)
return 600;
else if (packSize <= 80)
return 800;
else if (packSize <= 100)
return 1000;
else if (packSize <= 120)
return 1200;
else if (packSize <= 140)
return 1400;
else if (packSize <= 160)
return 1600;
else if (packSize <= 170)
return 1700;
else
return -1;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>ゆうパック送料検索</title>
</head>
<body>
<h1>ゆうパック送料検索</h1>
<p>同一都道府県内への配達、重量30kgまで</p>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="ser...
</asp:ScriptManager>
<asp:Label
ID="Label1"
runat="server"
Text="荷物の大きさ(縦・横・高さの合計): "
AssociatedControlID="PackageSizeList">
</asp:Label>
<asp:DropDownList
ID="PackageSizeList"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="PackageSizeList_Selec...
<asp:ListItem Value="0">(選択してください)<...
<asp:ListItem Value="60">60cmまで</asp:ListIt...
<asp:ListItem Value="80">80cmまで</asp:ListIt...
<asp:ListItem Value="100">100cmまで</asp:List...
<asp:ListItem Value="120">120cmまで</asp:List...
<asp:ListItem Value="140">140cmまで</asp:List...
<asp:ListItem Value="160">160cmまで</asp:List...
<asp:ListItem Value="170">170cmまで</asp:List...
</asp:DropDownList>
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="ResultLabel" runat="server...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Pack...
EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
}}
**UpdatePanelの制限 [#jbc89610]
このようにUpdatePanelは非常に簡単で、便利ですが、注意しな...
例えば、UpdatePanelの中に入れることのできないコントロール...
今回はこれでおしまいです。次回もASP.NET AJAXについて説明...
**参考 [#l5014b26]
-[[UpdatePanel Control Overview>http://asp.net/AJAX/Docum...
-[[UpdatePanel Control Tutorials>http://asp.net/AJAX/Docu...
-[[UpdatePanel Class>http://asp.net/AJAX/Documentation/Li...
**コメント [#t3c14c1b]
#comment
//これより下は編集しないでください
#pageinfo([[:Category/.NET]] [[:Category/ASP.NET]],2007-1...
ページ名:
▲
▼
[
トップ
] [
新規
|
子ページ作成
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]