jimmyjambles
jimmyjambles

Reputation: 1670

Form submission without reloading page

I have a usercontrol containing a few textboxes and a submit button which runs inside a larger page, I have a few panels in the usercontrol so that when the user clicks submit the panels I toggle the visibility of the form panel with a panel saying "you have submitted". The problem I am having is that when the form is submitted it refreshes the whole page. I am wondering if there is any quick modification I can make to the usercontrol to have it only refresh itself without rewiring the form in ajax?

protected void Button1_Click(object sender, EventArgs e)
{
    DatabaseConnection connection = new DatabaseConnection();

    //Verify if entry exists
    if (CheckValid())
    {
        //Register data
        pnlSuccess.Visible = true;
    }
    else
    {
        pnlDejaRepondu.Visible = true;
    }

    pnlForm.Visible = false;
}

Upvotes: 0

Views: 455

Answers (1)

suff trek
suff trek

Reputation: 39777

You can enclose content of the user control into an UpdatePanel.

UpdatePanel will cause partial postback of the user control content only, leaving the rest of the page intact.

Upvotes: 2

Related Questions