asp.net 2.0技巧3
来源:互联网 发布:ecs windows 编辑:程序博客网 时间:2024/05/01 17:42
今天看台湾章立民的书<<asp.net ajax 168范例》了,看到了讲updatepannel中如何设定
childrenastriggers的问题,当childrenastriggers设置为falase时,是很有用的(默认是true),
比如一个购物车,左边是商品的列表,用一个updatepannel里包住一个datalist,当点
datalist的书名时,在右边的一个updatepannel里的datalist里,显示这商品的具体信息。
关键部分如下:
左边部分
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="MyDataList" DataKeyField="书号" runat="server" Width="248px" DataSourceID="SqlDataSourceChtNorthwind">
<ItemTemplate>
<table cellpadding="10" style="font: 10pt verdana">
<tr>
<td valign="top">
<img id="Img1" alt="book image" align="top" border="1" src='<%# Eval("书号", "DisplayBookImage.ashx?Title_Id={0}") %>'
runat="server" style="width: 96px; height: 128px" />
</td>
<td valign="top" style="width: 339px">
<b>书名:<br />
</b>
<asp:LinkButton ID="Linkbutton1" Text='<%# Eval("书名") %>' CommandName="Select" runat="server"
Width="184px" />
<br>
<b>价格:</b><asp:Label ID="lblPrice" runat="server" Text='<%# Eval("价格", "{0:n0}") %>' /><br>
<div>
<asp:CheckBox ID="AddBag" runat="server" Text="加入购物袋" /><img src="Images/ShoppingBag.gif"
style="vertical-align: middle" />
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSourceChtNorthwind" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT * FROM [章立民研究室图书]"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
右边部分
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table cellpadding="5" width="100%" style="font: 10pt verdana">
<tr>
<td style="width: 312px; height: 461px;">
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSourceTargetBook"
DataKeyField="书号" Width="544px">
<ItemTemplate>
<table border="1" style="width: 576px">
<tr>
<td colspan="2" rowspan="1" style="background-color: #ffff99" valign="top">
<font color="#800000" size="3"><i><b>
<%#Eval("书名")%>
</b></i></font>
</td>
</tr>
<tr>
<td rowspan="7" style="width: 215px; background-color: #ffff99" valign="top">
<img src='<%# Eval("书号", "DisplayBookLargeImage.ashx?Title_Id={0}") %>' style="width: 336px;
height: 453px" /></td>
<td style="width: 14865899px; background-color: #ffff99;" valign="top">
<b>书号:</b><%#Eval("书号")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99;" valign="top">
<b>ISBN:</b><%#Eval("ISBN")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>类:</b><%#Eval("类别")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>价格:</b><%#Eval("价格", "{0:c}")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>作者:</b><%#Eval("作者")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99; height: 267px;" valign="top">
<b>内容特色:</b><br />
<%#Eval("内容特色")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99; height: 29px;" valign="top">
<a target="_blank" href="http://liminzhang.cnblogs.com/">
<img border="0" src="images/Noodle.jpg" title="前往立民讲堂"></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSourceTargetBook" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT * FROM dbo.章立民研究室图书 WHERE (书号 = @Title_Id)" DataSourceMode="DataReader">
<SelectParameters>
<asp:ControlParameter ControlID="MyDataList" Name="Title_Id" PropertyName="SelectedValue"
Size="9" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="MyDataList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
childrenastriggers的问题,当childrenastriggers设置为falase时,是很有用的(默认是true),
比如一个购物车,左边是商品的列表,用一个updatepannel里包住一个datalist,当点
datalist的书名时,在右边的一个updatepannel里的datalist里,显示这商品的具体信息。
关键部分如下:
左边部分
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="MyDataList" DataKeyField="书号" runat="server" Width="248px" DataSourceID="SqlDataSourceChtNorthwind">
<ItemTemplate>
<table cellpadding="10" style="font: 10pt verdana">
<tr>
<td valign="top">
<img id="Img1" alt="book image" align="top" border="1" src='<%# Eval("书号", "DisplayBookImage.ashx?Title_Id={0}") %>'
runat="server" style="width: 96px; height: 128px" />
</td>
<td valign="top" style="width: 339px">
<b>书名:<br />
</b>
<asp:LinkButton ID="Linkbutton1" Text='<%# Eval("书名") %>' CommandName="Select" runat="server"
Width="184px" />
<br>
<b>价格:</b><asp:Label ID="lblPrice" runat="server" Text='<%# Eval("价格", "{0:n0}") %>' /><br>
<div>
<asp:CheckBox ID="AddBag" runat="server" Text="加入购物袋" /><img src="Images/ShoppingBag.gif"
style="vertical-align: middle" />
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSourceChtNorthwind" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT * FROM [章立民研究室图书]"></asp:SqlDataSource>
</ContentTemplate>
</asp:UpdatePanel>
右边部分
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table cellpadding="5" width="100%" style="font: 10pt verdana">
<tr>
<td style="width: 312px; height: 461px;">
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSourceTargetBook"
DataKeyField="书号" Width="544px">
<ItemTemplate>
<table border="1" style="width: 576px">
<tr>
<td colspan="2" rowspan="1" style="background-color: #ffff99" valign="top">
<font color="#800000" size="3"><i><b>
<%#Eval("书名")%>
</b></i></font>
</td>
</tr>
<tr>
<td rowspan="7" style="width: 215px; background-color: #ffff99" valign="top">
<img src='<%# Eval("书号", "DisplayBookLargeImage.ashx?Title_Id={0}") %>' style="width: 336px;
height: 453px" /></td>
<td style="width: 14865899px; background-color: #ffff99;" valign="top">
<b>书号:</b><%#Eval("书号")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99;" valign="top">
<b>ISBN:</b><%#Eval("ISBN")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>类:</b><%#Eval("类别")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>价格:</b><%#Eval("价格", "{0:c}")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99" valign="top">
<b>作者:</b><%#Eval("作者")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99; height: 267px;" valign="top">
<b>内容特色:</b><br />
<%#Eval("内容特色")%>
</td>
</tr>
<tr>
<td style="width: 14865899px; background-color: #ffff99; height: 29px;" valign="top">
<a target="_blank" href="http://liminzhang.cnblogs.com/">
<img border="0" src="images/Noodle.jpg" title="前往立民讲堂"></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSourceTargetBook" runat="server" ConnectionString="<%$ ConnectionStrings:chtNorthwind %>"
SelectCommand="SELECT * FROM dbo.章立民研究室图书 WHERE (书号 = @Title_Id)" DataSourceMode="DataReader">
<SelectParameters>
<asp:ControlParameter ControlID="MyDataList" Name="Title_Id" PropertyName="SelectedValue"
Size="9" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="MyDataList" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
- asp.net 2.0技巧3
- asp.net 2.0技巧3
- ASP.NET 2.0技巧
- asp.net 2.0 技巧2
- ASP.NET 2.0 编程技巧
- asp.net 2.0 技巧2
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- ASP.NET 2.0 绑定高级技巧
- 装饰模式学习
- (转)Apache服务器使用.htaccess实现图片防盗链方法教程
- php里的include和require
- asp.net ajax技巧2
- asp.net 2.0 ajax技巧学习1
- asp.net 2.0技巧3
- (转)SQL Server高可用性部署实施
- asp.net 2.0 技巧2
- asp.net 2.0常见问题技巧1
- asp.net 2.0中显示主从关系另一个方法
- TOMCAT 5的一些优化笔记
- (转)遭遇PHP has encountered an Access Violation
- 策略模式笔记
- 数据调优好的文章收集1