Determining 'first load' state of a dynamically inserted control

Discussion in 'ASP .Net Building Controls' started by John Burke, May 5, 2004.

  1. John Burke

    John Burke Guest

    Hi Group,

    Is their an existing convenient method for determining if a usercontrol has
    been loaded for the first time? The usercontrol itself may be initially
    loaded on subsequent postbacks, not the initial page access.

    I am assuming I cannot use IsPostBack, as that appears to refer only to the
    page rather than the usercontrol. In other words, controls contained within
    the dynamically loaded usercontrol cannot rely on IsPostBack to determine
    that this is the first time they have been loaded. I have not experimented
    with this yet, so it would be nice if I was completely and utterly wrong in
    this assumption.

    John Burke, May 5, 2004
    1. Advertisements

  2. John Burke

    John Burke Guest

    Hi Scott,

    Thanks for your considered reply. I figured it would come to that. I had
    imagined it might be possible to imply first load if the control did not
    have LoadViewState called, but this does look like a reliable method.

    John Burke, May 5, 2004
    1. Advertisements

  3. Hi John,

    You can override LoadViewState and set a flag or something. You can count on
    LoadViewState not being called for the first request.

    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    Victor Garcia Aprea [MVP], May 5, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.