ich zu replizieren klar, dass das eine unglaublich alte Frage, aber es ist eine Antwort noch wert.
Worüber Sie sprechen, ist kein Benutzersteuerelement, sondern ein benutzerdefiniertes Steuerelement. Was Sie mit dem OutputCache machen wollen, können Sie einfach mit dem Context Cache tun.
In Ihrem Code, wo Sie die Daten und die Bindung an Ihre Dropdownlist werden immer etwas tun, wie folgt aus:
List<Object> listOfObjects = null;
//assuming a List of Objects... it doesn't matter whatever type of data you use
if (Context.Cache["MyDataCacheKey"] == null)
{
// data not cached, load it from database
listOfObjects = GetDataFromDB();
//add your data to the context cache with a sliding expiration of 10 minutes.
Context.Cache.Add("MyDataCacheKey", listOfObjects, null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
TimeSpan.FromMinutes(10.0),
System.Web.Caching.CacheItemPriority.Normal, null);
}
else
listOfObjects = (List<Object>)Context.Cache["MyDataCacheKey"];
DropDownList1.DataSource = listOfObjects;
DropDownList1.DataBind();
Vielen Dank! –