views:

23

answers:

2

this is very hard to explain and give code based on it. So thank you now if you even try to help

I have a form with a update panel. This posts the form and validates it. Returning a errorMessage string of any invalid field such as "Field xyz is a required field, Field abc needs to be a quantity"

When I enter incorrect date it posts back fine and displays the text in a div at the bottom of the page which the update panel is aimed at to update. (and only this it should be changing)

This works but the second time I hit say (say i enter invalid data twice) the Complete form will disappear leaving me with just the banner of the site and the error message that is returned.

Ive tried commenting out the entire of the code post back so that the button doesn't actually do anything but it still has the same problem(of course this time it wouldnt have a error message created)

So i can only think it is something to do with the updatepanel itself and how it works but i have been staring at this for ages and have no more ideas!

+1  A: 

Very difficult to answer this without some example code. Have a look at what your codebehind is doing to your page and be aware that within your update panel, your postback is actually an AJAX callback. Your page is executed again but only the contents of the update panel are re-renderd and only the same contents are supposed to be updated on the client side.

Often, when I have issues on the second or subsequent postback it is to do with initialisation code running when I don't want it to.

My advice is to look into where you are checking if (Page.IsPostback) and if (Page.IsCallback) and play around with these. Perhaps your need to protect your serverside code that handles the form within the following block:

if (Page.IsCallback)
{

}
Daniel Dyson
A: 

I found the issue (after about 5 hours) but don't understand it. The updatepanel that was disppearing had the updatepanel I was using outside of it

    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnTabs" />
    </Triggers>
</asp:UpdatePanel>
<asp:PlaceHolder runat="server" ID="phldActionButtons" />

The placeholder had inside it the control with my update panel I was using. The closing updatepanel you can see was the content of the form

By simply moving the placeholder inside of the contenttemplate it seems to have resolved the issue. (not sure why it would hide/remove a whole updatepanel which only relation to it was that it was the form it was validating on the postback!

Steve