This is something I initially knocked up so that I could add CSS to a page conditional on the query string present. I basically wanted to change the CSS if the page was showing a dialog.
It is a very simple control which extends the ASP.Net "Panel" class (which basically outputs a DIV). I added some Pre-Render logic to check for a query string value and only show the contents if that Query String is present.
Code
public class ConditionalQueryStringPanel : Panel
{ public String QueryString
{ get; set; }
protected override void OnPreRender(EventArgs e)
{ base.OnPreRender(e);
this.Visible = Page.ClientQueryString.Contains(QueryString);
}
}
In the example usage below I am using this panel to conditionally change the margin of one of my containers when the page is showing in a pop-up dialog
Usage
<MJH:ConditionalQueryStringPanel runat="server" QueryString="IsDlg=1">
<style type="text/css">
#contentBox {
margin-left: 0px;
} </style>
</MJH:ConditionalQueryStringPanel>
Something quite simple but hopefully you should be able to make use of it.
No comments:
Post a Comment
This blog has been moved to www.martinhatch.com
Note: only a member of this blog may post a comment.