paezinc
paezinc

Reputation: 339

ASP.Net UpdatePanel refresh after page load

I have a page that has some textboxes that are refreshed everytime page is loaded (Page_Load). Also have a table that takes too long to load (can't make it faster).

I thought using a UpdatePanel to load that table after textboxes are updated. I could use RegisterStartupScript (after textboxes updated) to update the UpdatePanel .

However, the UpdatePanel update always calls Page_Load, so the textboxes are always updated again. It's like UpdatePanel is useless.

How can this be solved?

Upvotes: 2

Views: 4472

Answers (3)

iandayman
iandayman

Reputation: 4467

You can check in Page_Load to see whether it is being called via a partial postback (i.e. from the updatepanel) and if it is then don't update the textboxes.

Upvotes: 1

Zeek2
Zeek2

Reputation: 426

You can check if it is a postback in the ASP.NET C# code-behind, e.g.:

if ( ! Page.IsPostBack )    

Or in clientside javascript thus:

<script type="text/javascript">
        function ClickHidenButton()
        {
            if (IsPostBack() != true)
                document.getElementById("hiddenAsyncTrigger").click();
        }

        function IsPostBack() {
             var ret = '<%= Page.IsPostBack%>' == 'True';
             return ret;
        }
</script>

Upvotes: 0

Prashant Lakhlani
Prashant Lakhlani

Reputation: 5806

Simple solution in your case is to use asp.net ajax timer along with update panel. Utilize the postback triggers and you are done.

see more here: http://msdn.microsoft.com/en-us/library/bb386404(v=vs.100).aspx

let me know if you need more help

Upvotes: 0

Related Questions