473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

@ OutputCache in usercontrol problem

Hi to All,

I am using <% @ OutputCache Duration="60"
VaryByParam="none" %> in my
usercontrol say "myControl.ascx". This user control has a
property say
"title".

Now am Dynamically Loading this control in "myPage.aspx"
like this
Control ctl = LoadControl("myControl.ascx").
and then performing casting operation in order to set the
property value
((myControl)ctl).title = "Welcome to my Site"

But when i run the page it gives me following error
System.InvalidCastException. Specified cast is not valid.

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="none" %> The page
successfully
executes.
Please suggest.

Thanx in advance
Marshal


Nov 17 '05 #1
3 2257
make sure that the header information for your control
file contains a class name
eg <%Control ClassName="myControl"%>

for further info on loading controls dynamically:

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconinstantiatingusercontrolsprogrammatica
lly.asp

also note: if the user control supports caching, the
object returned from this method is not actually a
UserControl, but a PartialCachingControl.
-----Original Message-----
Hi to All,

I am using <% @ OutputCache Duration="60"
VaryByParam="none" %> in my
usercontrol say "myControl.ascx". This user control has a
property say
"title".

Now am Dynamically Loading this control in "myPage.aspx"
like this
Control ctl = LoadControl("myControl.ascx").
and then performing casting operation in order to set the
property value
((myControl)ctl).title = "Welcome to my Site"

But when i run the page it gives me following error
System.InvalidCastException. Specified cast is not valid.

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="none" %> The page
successfully
executes.
Please suggest.

Thanx in advance
Marshal


.

Nov 17 '05 #2

Hi rory,

i have checked the className its correct
As u r telling me that return type is
PartialCachingControl not usercontrol so now how do i
access the property of the control.
i guess am doing wrong casting..

Marshall

-----Original Message-----
make sure that the header information for your control
file contains a class name
eg <%Control ClassName="myControl"%>

for further info on loading controls dynamically:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconinstantiatingusercontrolsprogrammatic ally.asp

also note: if the user control supports caching, the
object returned from this method is not actually a
UserControl, but a PartialCachingControl.
-----Original Message-----
Hi to All,

I am using <% @ OutputCache Duration="60"
VaryByParam="none" %> in my
usercontrol say "myControl.ascx". This user control has aproperty say
"title".

Now am Dynamically Loading this control in "myPage.aspx"
like this
Control ctl = LoadControl("myControl.ascx").
and then performing casting operation in order to set theproperty value
((myControl)ctl).title = "Welcome to my Site"

But when i run the page it gives me following error
System.InvalidCastException. Specified cast is not valid.

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="none" %> The page
successfully
executes.
Please suggest.

Thanx in advance
Marshal


.

.

Nov 17 '05 #3

Hi rory,

i have checked the className its correct
As u r telling me that return type is
PartialCachingControl not usercontrol so now how do i
access the property of the control.
i guess am doing wrong casting..

Marshall

-----Original Message-----
make sure that the header information for your control
file contains a class name
eg <%Control ClassName="myControl"%>

for further info on loading controls dynamically:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpguide/html/cpconinstantiatingusercontrolsprogrammatic ally.asp

also note: if the user control supports caching, the
object returned from this method is not actually a
UserControl, but a PartialCachingControl.
-----Original Message-----
Hi to All,

I am using <% @ OutputCache Duration="60"
VaryByParam="none" %> in my
usercontrol say "myControl.ascx". This user control has aproperty say
"title".

Now am Dynamically Loading this control in "myPage.aspx"
like this
Control ctl = LoadControl("myControl.ascx").
and then performing casting operation in order to set theproperty value
((myControl)ctl).title = "Welcome to my Site"

But when i run the page it gives me following error
System.InvalidCastException. Specified cast is not valid.

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="none" %> The page
successfully
executes.
Please suggest.

Thanx in advance
Marshal


.

.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Pete | last post by:
I am building an ASP.NET application and have just encountered something very strange which I would like explained if possible. In BaseForm.ascx I have the following <form> element: <form...
6
by: Tom Kiefer | last post by:
Question: If I have an ASP.NET User Control which defines/exposes a property that the page can use to specify a mode or data subset for the control to use, is there a way to tell the @OutputCache...
0
by: eriera1 | last post by:
I had one user-control that uses outputcache with shared="true" and in my local machine it shares the render through all the pages. But when I install my web app into another environment the...
1
by: Johan Nedin | last post by:
Hello! I am having a problem with the @OutputCache page directive and Web browser Back Buttons. Problem: After setting <%@ OutputCache Location="None" %> on my pages I get the "Warning!...
0
by: Pete | last post by:
I am building an ASP.NET application and have just encountered something very strange which I would like explained if possible. In BaseForm.ascx I have the following <form> element: <form...
5
by: Arpan | last post by:
I am using the following code to cache the page output for 60 seconds: <%@ OutputCache Duration="60" VaryByParam="*" %> <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As...
2
by: Nalaka | last post by:
Hi, I get the following error, I thought at random intervals. Then I realized, that this happens around the time tha page outputCache is set to expire. So I disabled the page output cache and the...
3
by: =?Utf-8?B?TWlndWVsIElzaWRvcm8=?= | last post by:
Hi, I have an ASP.NET 2.0 application that allows content search. Search is included in all pages and a cross postback to the search results page is performed with the text inserted by the user....
1
by: ABCL | last post by:
Hi All I have usercontrol on the page that I have added at design Time and cached it How can I remove the cached Usercontrol from outputcache. I want to remove cached version in session start...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.