views:

60

answers:

2

Hi,

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?

A: 

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.

jalpesh
ok well if I make it an asp.net button how to I place a trigger for the update panel?
Matt
+1  A: 

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

   <Triggers>
      <asp:PostBackTrigger ControlID="button" />
   </Triggers>
Exactly what I was looking for, thanks!
Matt
Of course this relies on using an ASP button, or at least some kind of control which can cause a postback.
Can the button stay as a div?
Matt