Is there any way to cache by browser a page or User Control
Try VaryByCustom=’browser’ in the user control/page.
How can I remove the cache of a page (cached with VaryByParam) for certain request params in code
You can attach a cache dependency to the response that is unique per query param, then invalidate the dependency for that particular param: // add cache item dependency on response string cacheKey = ‘xxx.aspx?’ + queryParam; Cache[cacheKey] = new object(); Response.AddCacheItemDependency(cacheKey); // invalidate the dependency string cacheKey = ‘xxx.aspx?’ + queryParam; Cache.Remove(cacheKey);
How can I set a page/control to be cached only for certain parameters
Let’s say you set your output cache directive as follows: <%@ OutputCache Duration=’86400′ VaryByParam=’RegionID’ VaryByCustom=’ProductID’ %> VaryByCustom – is a string that your application has to interpret in the GetVaryByCustomString override in the gloabal.asax file. Now, to avoid caching pages for certain ProductIDs you can set the cacheability to private or nocache from your page load for those pages as follows: VB.NET Response.Cache.SetCacheability(HttpCacheability.Private) C# Response.Cache.SetCacheability(HttpCacheability.Private) ;
How to check if an item already exists in a listbox
VB.NET Dim lstitem As ListItem = ListBox1.Items.FindByValue(‘<valuecheckedfor>’) If Not lstitem Is Nothing Then Response.Write(‘Item Exists’) Else Response.Write(‘Item Does not exist’) End If C# ListItem lstitem = ListBox1.Items.FindByValue(‘<valuecheckedfor>’); if ( lstitem !=null) { Response.Write (‘Does exist’); } else { Response.Write (‘Does not exist’); } You can also use FindByText instead of FindByValue.
How to make the listbox scroll down to show it’s last entry when the page loads?
<p> <asp:ListBox id=’ListBox1′ runat=’server’></asp:ListBox> </p> <p> <asp:Button id=’buttonAdd’ runat=’server’ Text=’Add’></asp:Button> </p> In button Click Event VB.NET ListBox1.Items.Add(DateTime.Now.ToString(‘MMM dd, yyyy’) + ‘ ‘ + DateTime.Now.ToString(‘t’)) Dim scrollScript As String scrollScript &= ‘<script language=’javascript’>’ scrollScript &= ‘document.forms[0].ListBox1.selectedIndex ‘ & _ ‘ = document.forms[0].ListBox1.options.length-1;’ scrollScript &= ‘<‘ & ‘/’ & ‘script>’ Page.RegisterStartupScript(”, scrollScript) C# ListBox1.Items.Add(DateTime.Now.ToString(‘MMM dd, yyyy’) + ‘ ‘ + DateTime.Now.ToString(‘t’)); string scrollScript=” ; scrollScript += ‘<script language=’javascript’>’; scrollScript += ‘document.forms[0].ListBox1.selectedIndex = document.forms[0].ListBox1.options.length-1;’; scrollScript += ‘<‘ + ‘/’ + ‘script>’; Page.RegisterStartupScript(”, scrollScript);