In a module i have a sub that create modalpopup and show result of action..I dont wanna drop & drag modalpopup extender and make html complex therefore i do that in code-behind.I wonder that Can i cache my panel and then get it from cache?It takes time to crate these panels.Or do u have recommodations to improve performance of this Sub?I use Script Combining,JS minify and Css minify.My sub's code is here.
Public Sub Raise_Alarm(ByVal p_Page As Page, ByRef p_AssignedButton As System.Web.UI.WebControls.Button, ByVal p_Message As String, Optional ByVal p_Type As MessageType = MessageType.Success) Dim placeHolder As PlaceHolder = p_Page.FindControl("plcMsg") Dim lblStatus As System.Web.UI.WebControls.Label lblStatus = p_Page.FindControl("lblStatus") lblStatus.Width = Unit.Percentage(100) lblStatus.Font.Name = "verdana" lblStatus.Font.Size = System.Web.UI.WebControls.FontUnit.XSmall 'Create Modalpopup extender Dim mdlMessage As New AjaxControlToolkit.ModalPopupExtender 'Create Divs Dim pnlMessage As New System.Web.UI.WebControls.Panel Dim pnlFrame As New System.Web.UI.WebControls.Panel Dim pnlContainer As New System.Web.UI.WebControls.Panel Dim pnlHeader As New System.Web.UI.WebControls.Panel Dim pnlMsg As New System.Web.UI.WebControls.Panel Dim pnlBody As New System.Web.UI.WebControls.Panel Dim pnlFooter As New System.Web.UI.WebControls.Panel Dim pnlRight As New System.Web.UI.WebControls.Panel '******* 'Create Ok Buttons Dim btnOk As New System.Web.UI.WebControls.Button 'Create Message Label Dim lblMessage As New System.Web.UI.WebControls.Label Dim myheader As New System.Web.UI.WebControls.Label 'Assign Properties pnlMessage.ID = "pnlMessage" pnlMessage.CssClass = "modal-dialog" pnlMessage.Style.Add("display", "none") pnlFrame.ID = "pnlframe" pnlFrame.CssClass = "frame" pnlContainer.ID = "container" pnlContainer.CssClass = "container" pnlHeader.ID = "header" pnlHeader.CssClass = "header" myheader.ID = "headerlabel" myheader.Text = "Warning" pnlMsg.ID = "msg" pnlMsg.CssClass = "msg" pnlBody.ID = "body" pnlBody.CssClass = "body" pnlFooter.ID = "footer" pnlFooter.CssClass = "footer" pnlRight.ID = "right" pnlRight.CssClass = "right" btnOk.ID = "btnOk" btnOk.Width = Unit.Pixel(50) btnOk.Text = "Ok" btnOk.CssClass = "but" btnOk.OnClientClick = "Dispose()" lblMessage.ID = "lblMessage" lblMessage.Text = p_Message lblMessage.CssClass = "body" If p_Type = MessageType.Success Then lblStatus.ForeColor = System.Drawing.Color.Blue lblStatus.Text = p_Message lblStatus.Visible = True ElseIf p_Type = MessageType.Error Then lblStatus.ForeColor = System.Drawing.Color.Red End If pnlRight.Controls.Add(btnOk) pnlFooter.Controls.Add(pnlRight) pnlBody.Controls.Add(lblMessage) pnlBody.Controls.Add(pnlFooter) pnlMsg.Controls.Add(myheader) pnlHeader.Controls.Add(pnlMsg) pnlContainer.Controls.Add(pnlHeader) pnlContainer.Controls.Add(pnlBody) pnlFrame.Controls.Add(pnlContainer) pnlMessage.Controls.Add(pnlFrame) With mdlMessage .TargetControlID = p_AssigedButton.ID .PopupControlID = pnlMessage.ID .ID = "mdlMessage" .BackgroundCssClass = "modalBackground" .OkControlID = btnOk.ID .Page = p_Page End With placeHolder.Controls.Add(pnlMessage) placeHolder.Controls.Add(mdlMessage) mdlMessage.Show() End Sub