sean
sean

Reputation: 437

AJAX completely disabled postback on button click event

I've added a ScriptManager and UpdatePanel in my user control but now the page is not posting back, at all. This is the only instance of a ScriptManager on the page. I'm using VS 2010 and my project is compiled with the 4.0 framework. EnablePartialRendering is set to true in the ScriptManager control. Could I be missing an assembly reference/registration, somewhere?

<asp:ScriptManager ID="ScriptManager1" runat="server" /> 

<asp:UpdatePanel ID="UpdatePanel1" runat="Server" UpdateMode="Conditional">
    <ContentTemplate> 
        <asp:ImageButton ID="SignUp" runat="server" AlternateText="SignUp"
            class="tips_button" ImageUrl="/~/myimage.ashx"
            onclick="SignUp_Click" ToolTip="Find" /> 
    </ContentTemplate>
    <Triggers> 
        <asp:AsyncPostBackTrigger ControlID="SignUp" EventName="Click" /> 
    </Triggers> 
</asp:UpdatePanel>

Upvotes: 0

Views: 1469

Answers (2)

Kelsey
Kelsey

Reputation: 47726

You don't need a Trigger setup for any controls within an UpdatePanel ContentTemplate. By default all controls will postback using ajax and then new content within the ContentTemplate will be rendered.

You have a Trigger setup for the control that is already inside so that could be what is causing the problem so remove it as it is not necessary. You use a Trigger when you want the UpdatePanel to get 'triggered' by a control outside of it's ContentTemplate.

Everything else looks ok. Make sure you have SignUp_Click setup in your codebehind and test it by putting a break point on some code in your Page_Load which should be hit anytime there is a postback.

Side issue: The code ImageUrl="/~/myimage.ashx" in your ImageButton looks a little odd... that extra slash at the beginning might cause some problems.

Upvotes: 1

James Johnson
James Johnson

Reputation: 46047

Try changing UpdateMode to Always instead of Conditional. Also, for something this simple you shouldn't need to specify any triggers. If no triggers are specified, the control assumes that everything should be asynchronous.

I would also check to make sure that required field validators aren't interfering with the postback. To test this, set the CausesValdiation property of the ImageButton to false.

Upvotes: 0

Related Questions