Reputation:
I'm using a template control in a web application. At the moment, everything OnLoad is happening even if the page is a postback (understandably). How do I access an isPostback property in this method to run the necessary checks, just as I would if it were a pages code-behind?
Upvotes: 1
Views: 131
Reputation: 43087
You can add code blocks to your markup:
<% if (Page.IsPostBack) { %>
<div> markup </div>
<% } %>
Of course, I'm assuming you're asking about adding an IsPostBack
check in markup. I suppose you could also mean a CustomControl
. In that case, you can still use Page.IsPostBack
in your CustomControl
class.
protected override void OnLoad(EventArgs args, object source)
{
if (Page.IsPostBack)
{
// stuff that should only happen during POST
}
}
Upvotes: 2