@ OutputCache in usercontrol problem

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default @ 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






    marshal Guest

  2. Similar Questions and Discussions

    1. usercontrol problem
      Hi, I am just progamming using asp.net, and I want create a usercontrol to display some dynamic(from database) contents. Is this possible? ...
    2. Problem with datagrid in userControl
      Hi I have a UserControl wich contains a datagrid .The Usercontrol is add dynamicly to the page. My problem is that i have to click twice on the ...
    3. Problem with a usercontrol
      Dear Friends, I'm working on a web based(ASP.Net) project. This project contains multiple web projects. I want to use a usercontrol which has been...
    4. Use LoadControl to load a usercontrol but the webcontrol in the usercontrol can not AutoPostBack
      a uscontrol test.ascx have a dropdownlist web control the dropdownlist's AutoPostBack property is set "true" but when i use...
    5. Programatically remove @OutputCache
      I orignally posted this question. Thanks for your response. I can not check this variable when the page is initalised or loaded as for cached...
  3. #2

    Default @ OutputCache in usercontrol problem

    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:

    [url]http://msdn.microsoft.com/library/default.asp?[/url]
    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
    >
    >
    >
    >
    >
    >
    >.
    >
    Rory Guest

  4. #3

    Default @ OutputCache in usercontrol problem


    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:
    >
    [url]http://msdn.microsoft.com/library/default.asp?[/url]
    >url=/library/en-
    >us/cpguide/html/cpconinstantiatingusercontrolsprogrammatic
    a
    >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
    >>
    >>
    >>
    >>
    >>
    >>
    >>.
    >>
    >.
    >
    Marshal Guest

  5. #4

    Default @ OutputCache in usercontrol problem


    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:
    >
    [url]http://msdn.microsoft.com/library/default.asp?[/url]
    >url=/library/en-
    >us/cpguide/html/cpconinstantiatingusercontrolsprogrammatic
    a
    >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
    >>
    >>
    >>
    >>
    >>
    >>
    >>.
    >>
    >.
    >
    Marshal Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139