?
Solved

AJAX Form Submission using UpdatePanel and UserControls

Posted on 2014-03-07
1
Medium Priority
?
400 Views
Last Modified: 2014-03-20
Hi all,

I have a number of usercontrols which aI want to seamlessly run through using AJAX (i.e. without leaving the page).

1. Signup form
2. Confirmation Form.
3. Completion Form.

When the user first navigates to the site they will be navigated to the Signup form. Once this is completed they will click the 'signup' button in the .ascx control.

Now from here I want to load move to the next usercontrol. Now how can I bubble the click request from the ascx control to the page? and set the current usercontrol to the viewstate in case of postback?

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

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>   
            <asp:PlaceHolder ID="PlaceHolderPageContent" runat="server"></asp:PlaceHolder>
        </ContentTemplate>
    </asp:UpdatePanel>

Open in new window


private const string BASE_PATH = "~/usercontrols/";

    private string LastLoadedControl
    {
        get
        {
            return ViewState["LastLoaded"] as string;
        }
        set
        {
            ViewState["LastLoaded"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LastLoadedControl = BASE_PATH + "SignupForm.ascx";
        }

        LoadUserControl();
    }

    private void LoadUserControl()
    {
        string controlPath = LastLoadedControl;

        if (!string.IsNullOrEmpty(controlPath))
        {
            PlaceHolderPageContent.Controls.Clear();
            UserControl uc = (UserControl)LoadControl(controlPath);
            PlaceHolderPageContent.Controls.Add(uc);
        }
    }

Open in new window

0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
OriNetworks earned 1500 total points
ID: 39912523
Do you have any objections to having all of the UserControls in the Content section and set Visible="False" as the default for all of them? You can then use the pageload event to check which controls should be visible. Otherwise you would need to dynamically load all controls on every postback and that can get messy.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question