Click here to Skip to main content
15,885,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a page with 5 tabs on it, containing fields that the user fills out. I would like to save the data from each tab as the user navigates between tabs (postback). What is the best way to do this? I have tried javascript (no postback here) and using a case statement triggered by a case statement. In the second method, for some reason the navigation does not occur and the data is cleared on the button click.

JavaScript method:
JavaScript
$(function () {
            $("#<%= btnBack.ClientID%>").css("display", "none");
            $("#<%= btnNext.ClientID%>").click(function (event) {
                $("#tabIncident").tabs("option", "active", $("#tabIncident .ui-tabs-active").index() + 1);
                //event.preventDefault();
            });

            $("#<%= btnBack.ClientID%>").click(function (event) {
                $("#tabIncident").tabs("option", "active", $("#tabIncident .ui-tabs-active").index() - 1);
                //event.preventDefault();
            });



C# Case Statement Method:

C#
switch (e.CommandName)
        {

            case "BACK":
                if (_eventID == 0)
                {
                    Save(false, Mode.Edit, Status.Save);
                    RedirectTo(pageLocation - 1);
                }
                else
                    Update(_eventID, false, Status.Save);
                    RedirectTo(pageLocation - 1);
                break;
            case "NEXT":
                if (_eventID == 0)
                {
                    Save(false, Mode.Edit, Status.Save);
                    RedirectTo(pageLocation + 1);
                }
                else
                    Update(_eventID, false, Status.Save);
                RedirectTo(pageLocation + 1);
                break;
Posted
Comments
Arkadeep De 29-Mar-15 3:29am    
If you are using the below C# code you can use ViewState to save your data temporarily. And after that on a final button put those data into db or whatever your functionality does.

1 solution

Hi,

What type of project template you have used. If you are using MVC then you can use action method to post and get data from each tab. If it is a simple web application you can use ashx handler or webmethod to post and get data tab wise which is known as lazy loading. For any of the above type of application you can use $.ajax to post and get data.

here is the best article to get the data from server side for the selected tab which you can modify to post data instead of fetching data

http://www.mikesdotnetting.com/article/102/lazy-loading-jquery-tabs-with-asp-net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900