Back to Devexpress

ASPxPopupControlBase.HeaderTemplate Property

aspnet-devexpress-dot-web-dot-aspxpopupcontrolbase-330b83f8.md

latest7.8 KB
Original Source

ASPxPopupControlBase.HeaderTemplate Property

Gets or sets a template used to display the default window‘s header.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue(null)]
public virtual ITemplate HeaderTemplate { get; set; }
vb
<DefaultValue(Nothing)>
Public Overridable Property HeaderTemplate As ITemplate

Property Value

TypeDefaultDescription
ITemplatenull

An object that supports the System.Web.UI.ITemplate interface and contains a template used to display a window’s header.

|

Remarks

Use the HeaderTemplate property to control the default window’s header. The template defined using this property replaces the window header - in particular, the image, text and close button displayed with the header.

Note that any style settings defined for the header via the ASPxPopupControl.HeaderStyle (PopupControlStyles.Header for ASPxDockPanel) property are still in effect for the window’s header, whose content is specified using the HeaderTemplate property.

Note

For ASPxPopupControl only:

If the ASPxPopupControl.Windows collection is not empty, the HeaderTemplate property is not in effect. In this case, a common header template for all popup windows from the ASPxPopupControl.Windows collection can be defined via the ASPxPopupControl.WindowHeaderTemplate property. An individual window’s header template can be specified by using the window’s PopupWindow.HeaderTemplate property.

Note

Once a template defined via the HeaderTemplate property is created within a control, it is instantiated within a container object of the PopupControlTemplateContainer type. This container object exposes a set of specific properties to which the template’s child controls can be bound.

Online Example

View Example: Popup Control for ASP.NET Web Forms - How to create a custom close button

Example

The ASPxPopupControl does not allow a developer to prevent a PopupControl from being hidden when the CloseButton is clicked based on a custom criteria. A possible solution for this limitation is to use templates. You should add a button to the PopupControl's HeaderTemplate container and decide whether a PopupControl should be closed or not when this button is clicked.

csharp
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e) {

    }
}
aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" MasterPageFile="~/MasterPage.master"%>

<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=79868b8147b5eae4"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="CC" runat="Server">
    <input id="Button1" style="width: 325px" type="button" value="Click button to show PopupControl" />

    <dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" PopupElementID="Button1" ClientInstanceName="popupControl"
        ShowCloseButton="False">
        <HeaderTemplate>
            <div style="text-align:right;">
            <input id="btn" type="button" value="close" onclick="
                if(document.getElementById('checkBox').checked)
                    popupControl.Hide();
            "/>            
            </div>
        </HeaderTemplate>
        <ContentCollection>
            <dxpc:PopupControlContentControl runat="server">
                <label id="lbl">Check CheckBox to be able to close the PopupControl by clicking the Hide button</label>
                <input id="checkBox" style="width: 32px" type="checkbox"/>
                </dxpc:PopupControlContentControl>
        </ContentCollection>
    </dxpc:ASPxPopupControl>
</asp:Content>
aspx
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" MasterPageFile="~/MasterPage.master"%>

<%@ Register Assembly="DevExpress.Web.v8.1, Version=8.1.6.0, Culture=neutral, PublicKeyToken=9B171C9FD64DA1D1"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>

<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" ID="CC" runat="Server">
    <input id="Button1" style="width: 325px" type="button" value="Click button to show PopupControl" />

    <dxpc:ASPxPopupControl ID="ASPxPopupControl1" runat="server" PopupElementID="Button1" ClientInstanceName="popupControl"
        ShowCloseButton="False">
        <HeaderTemplate>
            <div style="text-align:right;">
            <input id="btn" type="button" value="close" onclick="
                if(document.getElementById('checkBox').checked)
                    popupControl.Hide();
            "/>            
            </div>
        </HeaderTemplate>
        <ContentCollection>
            <dxpc:PopupControlContentControl runat="server">
                <label id="lbl">Check CheckBox to be able to close the PopupControl by clicking the Hide button</label>
                <input id="checkBox" style="width: 32px" type="checkbox"/>
                </dxpc:PopupControlContentControl>
        </ContentCollection>
    </dxpc:ASPxPopupControl>
</asp:Content>
vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class MasterPage
    Inherits System.Web.UI.MasterPage
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    End Sub
End Class

See Also

FooterTemplate

WindowHeaderTemplate

HeaderTemplate

ASPxPopupControlBase Class

ASPxPopupControlBase Members

DevExpress.Web Namespace