User Control Caching - Details -
02-01-2005
, 09:43 AM
Sorry, maybe my previous question was rather confusing.
************************************
I have User Control:
[uc_button.ascx]
<%@ OutputCache Duration=60 VaryByparam="none" %>
<%@ Control Language="vb" ... %>
<asp:Button id="btnButtonCached" Text="Cached Button"
runat="server"></asp:Button>
************************************
I added this User Control to my WebForm and I want to add handler to the
button.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim m As Control
m = LoadControl("uc_button.ascx")
PlaceHolder1.Controls.Add(m)
If TypeOf m Is uc_button Then
AddHandler CType(m, uc_button).btnButtonCached.Click, AddressOf btnKlik
Else
If TypeOf m Is PartialCachingControl Then
If Not CType(m, PartialCachingControl).CachedControl Is Nothing Then
AddHandler CType((CType(m, PartialCachingControl)).CachedControl,
uc_button).btnButtonCached.Click, AddressOf btnKlik
End If
End If
End If
End Sub
Problem is that after first postback, CachedControl is Nothing, so no
handler is added. What is wrong there?
Thanks!
Vlado |