Sam
Sam

Reputation: 4339

Conditionally causing a full postback on a button in an UpdatePanel

Is it possible to cause a full postback on a button, conditionally, that is within an UpdatePanel?

The reason for this is that 1) The page is dynamically built and it is a control, so I can't use the collection of the update panel, and 2) I will only be doing a full postback under certain situations.

The "certain situations" will be evaluated by JavaScript.

Upvotes: 0

Views: 859

Answers (1)

Roopesh Shenoy
Roopesh Shenoy

Reputation: 3447

Why don't you add a postbacktrigger to the updatepanel with the controlid of the button? Thats the best way to do it.

If you want to programmatically add the trigger depending on certain conditions, you can do this while rendering the page.

    PostBackTrigger t = new PostBackTrigger();
    t.ControlID = btn.ClientID;
    updatePanel1.Triggers.Add(t);

Upvotes: 1

Related Questions