473,748 Members | 4,951 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

@ OutputCache in usercontrol problem

Hi to All,

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

Now am Dynamically Loading this control in "myPage.asp x"
like this
Control ctl = LoadControl("my Control.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.InvalidC astException. Specified cast is not valid.

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

Thanx in advance
Marshal


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

for further info on loading controls dynamically:

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

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

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

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

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

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="no ne" %> 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
PartialCachingC ontrol 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="myCo ntrol"%>

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

also note: if the user control supports caching, the
object returned from this method is not actually a
UserControl, but a PartialCachingC ontrol.
-----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.asp x"
like this
Control ctl = LoadControl("my Control.ascx").
and then performing casting operation in order to set theproperty value
((myControl)c tl).title = "Welcome to my Site"

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

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="no ne" %> The page
successfull y
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
PartialCachingC ontrol 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="myCo ntrol"%>

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

also note: if the user control supports caching, the
object returned from this method is not actually a
UserControl, but a PartialCachingC ontrol.
-----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.asp x"
like this
Control ctl = LoadControl("my Control.ascx").
and then performing casting operation in order to set theproperty value
((myControl)c tl).title = "Welcome to my Site"

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

And the beauty of this problem is that when i remove the
line <% @
OutputCache Duration="60" VaryByParam="no ne" %> The page
successfull y
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
1209
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 ID="formBaseForm" method="post" runat="server"> <!-- Banner UserControl --> <PW:Banner runat="server" ID="Banner1" /> <!-- Initial UserControl -->
6
2742
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 directive to vary its cache based on that property value? I.e., I have: <my:control runat="server" id="mcOne" Flag="One" /> <my:control runat="server" id="mcTwo" Flag="Two" />
0
1272
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 usercontrol don't share the render HTML and it uses a diferent copy for every page. I changed the shared property to shared="True" and in my local machine continues working well. The surprise is that in the other environment works fine!! What is the...
1
6431
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! Page has expired" error message, when pushing the Back Button in my Web browser.
0
1073
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 ID="formBaseForm" method="post" runat="server"> <!-- Banner UserControl --> <PW:Banner runat="server" ID="Banner1" /> <!-- Initial UserControl -->
5
2162
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 EventArgs) lblOutput.Text = "Welcome, " & Request.Params("id") & " The time now is " & DateTime.Now.ToString("T") End Sub </script>
2
2680
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 problem went away. I put in the outputcache back and the problem is back. I am using forms authentication... and asp.net 2.0. Have you seen this problem before... any help is deeply appreciated.
3
3591
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. The search results also allows refining the search and a search button that performs a postback triggers the search. Many of the web pages in the web site have an OutputCache directive and the search results page does not. When I run the first...
1
1968
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 event I have tried to remove it using "HttpResponse.RemoveOutputCacheItem(path);" b but it doesn't work Thanks
0
8989
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9243
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.