views:

40

answers:

3

Hi,

I have the following ASPX code:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
                        <asp:UpdatePanel runat="server" ID="UpdatePanel" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:Button runat="server" ID="UpdateButton1" OnClick="NextImg_Click" Text="Update" />
                                <asp:Repeater runat="server" ID="urlsUpdateRepeater">
                                    <ItemTemplate>
                                        <!-- THIS WOULD BE A LOOP FROM HERE -->
                                        <!-- OPENS RESULT ITEM DIV CONTAINER -->
                                        <div id="result_item">
                                        <a href="<%# Eval("myUrl") %>" target="_blank">
                                                                    <%# Eval("urlPageTitle")%></a>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ContentTemplate>
                        </asp:UpdatePanel>

I have a NextImg_Click() event which works fine.

I use this code for DataBind... what is the Update method?

urlsUpdateRepeater.DataSource = resultsCollection;
urlsUpdateRepeater.DataBind();

Everything would appear to be in order. But every time the Update button is clicked it re-renders the whole page instead of the partial-postback UpdatePanel only.

It is driving me completely mad as I can't see anything wrong with the code. Is there some simple thing I'm missing?! Please help!

The search and data is displayed correctly (inside the panel) it just will not do a partial postback.

Appreciate your help with my noob problems!

A: 

Because the button is inside your UpdatePanel's ContentTemplate, it is unnecessary to take any extra action to get a partial page postback.

Try removing the line from your Page_Load() method.

kbrimington
Tried that made no difference :(
AlexW
A: 

Taken from MSDN:

Use the RegisterAsyncPostBackControl method to register controls outside an UpdatePanel control as triggers for asynchronous postbacks, and to potentially update the content of an update panel. To update an UpdatePanel control programmatically, call the Update method.

So, you're control (UpdateButton1) is inside the UpdatePanel, no need for the ScriptManager1.RegisterAsyncPostBackControl call - ditch it and your problem is solved.

RPM1984
I knew that bit already from reading MSDN... it's still not working.
AlexW
The whole page is posted back... :(
AlexW
Have you set the "EnablePartialRendering" attribute on your ScriptManager reference?<asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server">. Also try adding the Button as the async trigger: <Triggers> <asp:AsyncPostBackTrigger ControlID="UpdateButton1" EventName="Click" /> </Triggers>
RPM1984
I did try that one yes, again no change.... I am starting to think it might be the Event handler method. I have used UpdatePanel.Update() after the databind but I'm clearly not doing it right as it also did nothing.
AlexW
Tried both of those...
AlexW
Yep, sounds like it something else causing the problem. Take out the stuff in ItemTemplate - just have a label with runat=server. Then on the NextImgClick event handler, change the text of the label. See if that works (keep it simple first, then go from there). You dont need to call UpdatePanel.Update(). Way to think about coding with UpdatePanel is get things working first normally with a regular postback. Then wrap what you what to asynchronously update in the UpdatePanel, that is all the changes that are required (in most scenarios)
RPM1984
A: 

The problem was that my <form> tag was nested further into the document than it's corresponding end tag (with Warning!)...

Upon moving my form tag - it worked!

Entirely my fault, thanks guys.

AlexW
Hehe, its always something simple. =)That's why when working with UpdatePanels, code everything normally first (full postback), then work on the AJAX. (as i said in my comment).
RPM1984
Yep, best to break down the problem... cheers... :)
AlexW