Pergunta

Eu tenho um modal em uma página que também contém um controle do usuário.

Ao clicar no botão 'OK' no modal, eu gostaria de atualizar um AtualizePanel que está contido no controle do usuário na página.

Atualmente, o botão 'OK' no Modal faz um postback de página inteira, gostaria de apenas atualizar o painel, mas não tenho certeza de como adicioná -lo como um gatilho, pois não está no controle que o UpdatePanel está.

Obrigado.


Eu tenho uma resposta parcial ... posso atualizar o painel uma vez fazendo isso:

Dim addTrigger As New AsyncPostBackTrigger
addTrigger.ControlID = MyButton.ID
addTrigger.EventName = "Click"
MyUserControl.GetUpdatePanel.Triggers.Add(addTrigger)

Isso causará um pós-zagueiro parcial na primeira vez, mas depois da primeira vez, causa uma página inteira recarregar. Alguma ideia?

Foi útil?

Solução

You can explicitly add the OK button as a AsyncPostBackTrigger for the UpdatePanel.

In the aspx markup for the UpdatePanel:

<asp:UpdatePanel ID="updPanel" runat="server">
    <ContentTemplate>
    ....
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="the control" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

or in the code-behind:

protected override void OnInit(EventArgs e)
{
    AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
    trigger.ControlID = "the Control";
    trigger.EventName = "Click";

    updPanel.Triggers.Add(trigger);

    base.OnInit(e);       
}

Outras dicas

Maybe I am missing some subtlety here, but can't you just call the Update() method on the Update Panel?

You can use the following pattern to control a panel postback in JavaScript:

var prm = Sys.WebForms.PageRequestManager.getInstance(); 
prm._panelsToRefreshIDs = UPComments.uniqueID;
prm._doPostBack(eventTarget,eventArgument);
theForm.submit();

Can't you just add an AsyncPostBackTrigger programmatically from the code-behind?

Like This ?

just put the contents of the Panel in an update panel sothat you have:

Your user control here.

this will also prevent the popup from disapearing until you want it to.

In your code behind you can then call it with popup.show(0 or pop.hide() and link these to your user control by addin gan event ot it and handling it inyour pages code behind. this way your user control can direct the popup what to do and when. you can even for it to update hte update panel if you needed for some reason.


for the case above tha tI just realized is tha tyou wan to updat ehte panel in the control. Create a method i nthe control that calls the update method o teh update panel an dthen fire that event from your page. It's the same principal in reverse. By utilizing event well you can wire up your application to do some pretty cool stuff.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top