在一個模塊中,我有一個創建modalpopup和顯示行動的結果的子..我不想丟棄&拖動modalpopup擴展和使HTML複雜,因此我在代碼隱藏這樣做。我想知道我可以緩存我的面板,然後從緩存中獲取它嗎?需要時間來裝箱這些面板。或者你有推薦來改善這個Sub的性能嗎?我使用Script Combining,JS minify和Css minify。我的子代碼在這裏。控制緩存在asp.net
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
你試過HttpContext.Current.Cache ? – 2009-10-25 09:40:05
不,我沒試過。我可以用它來控制嗎? – Alexander 2009-10-25 10:00:05
看看右邊的相關問題,例如:http://stackoverflow.com/questions/44757/how-to-cache-asp-net-user-controls – 2009-10-25 12:06:55