Question

I have this layout:

<div runat="server" OnClick="ChangeText()" id="button">Ok</div>
<asp:UpdatePanel id="updater" runat="server">
    <ContentTemplate>
        <div id="text">Hello</div>
    </ContentTemplate>
</asp:UpdatePanel>

I would like to have it so that when the button is clicked, the function ChangeText() gets called on the server - that function then updates the label in the UpdatePanel like so...

public void ChangeText() {
    text.InnerText = "Goodbye";
}

How do I wire up the button so that it triggers the update for the updater?

Was it helpful?

Solution

If I understand your question correctly, add this below your node (inside the node).

   <Triggers>
      <asp:PostBackTrigger ControlID="button" />
   </Triggers>

OTHER TIPS

Why are you doing that with div. Instead of this you need to do other way like use the asp.net button and give the stylesheet for that button same like the div and place a trigger for update panel on button's click event.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top