s Control
'' Get a reference to the ScriptManager object for the page
'' if one exists.
Dim sm As ScriptManager = ScriptManager.GetCurrent(Page)
If sm Is Nothing OrElse Not sm.EnablePartialRendering Then
'' If partial rendering is not enabled, set the parent
'' and container as a basic control.
container = New Control()
parent = container
Else
'' If partial rendering is enabled, set the parent as
'' a new UpdatePanel object and the container to the
'' content template of the UpdatePanel object.
Dim up As UpdatePanel = New UpdatePanel()
container = up.ContentTemplateContainer
parent = up
End If
AddDataboundControls(container)
Controls.Add(parent)
End Sub
下面的示例演示一个自定义控件,如果已启用部分页呈现,该控件中将包含一个 UpdatePanel。
<%@ Page Language="VB" AutoEventWireup="true" %>
<%@ Register Namespace="UpdatePanelTutorialCustom.VB" TagPrefix="sample" % >
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Browse Products</title>
<script runat="server">
Protected Sub ProductsView1_RowCommand(ByVal sender As Object, ByVal e As EventArgs)
ShoppingCartList.DataSource = ProductsView1.Cart
ShoppingCartList.DataBind()
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="false" />
<h2>Browse Products</h2>
<sample:ProductsView runat="server" ID="ProductsView1" PageSize="5" OnRowCommand="ProductsView1_RowCommand" />
<asp:UpdatePanel runat="server" ID="CartUpdatePanel">
<ContentTemplate>
<h3>Selected Items</h3>
<asp:BulletedList BulletStyle="numbered" runat="server" ID="ShoppingCartList" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Imports??System??
Imports??System.Data??
Imports??System.Configuration
Imports??System.Collections
Imports??System.Web
Imports??System.Web.Security
Imports??System.Web.UI.WebControls
Imports??System.Web.UI.WebControls.WebParts
Imports??System.Web.UI.HtmlControls
Imports??System.Web.UI??
Imports??System.Dra
|