AJAX Tab with save and proceed option [Resolved]

Posted by Write2varun under ASP.NET AJAX on 3/20/2014 | Points: 10 | Views : 1467 | Status : [Member] | Replies : 3
Hi,

I'm Using AJAXControlToolKit Tab Controller to create Tab.

In that in Using iframe to add different page.

I Added the tab in the page (TabPage.aspx) and called all the page (ChildPage1.aspx, ChildPage2.aspx,ChildPage3.aspx,ChildPage4.aspx) from that page

I want to add save and proceed Button in the TabPage.aspx when the user click the button then it should save the data in the selected tab and proceed to the next tab i.e. If the user is at ChildPage1.aspx then the values should be saved in the ChildPage1.aspx and he should proceed to the page ChildPage2.aspx




Responses

Posted by: Write2varun on: 3/21/2014 [Member] Starter | Points: 25

Up
0
Down

Resolved
here is the solution if some one needs
http://forums.asp.net/post/5656234.aspx

Write2varun, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A2H on: 3/20/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,
You can use the TabContainer's ActiveTab property to change the tab once after you save data from each tabs.
Sample Code:
// Proceed  to Second Tab after saving the details

TabContainer1.ActiveTab = TabContainer1.Tabs[1];

To Save the Details to Database you can use the below code
//Create a using statement to house your connection

using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["YourConnectionStringValue"].ConnectionString))
{
// Open your connection
cn.Open();

// Provide the query string with a parameter placeholder.
// Here change the columnames and table names as per you table
string sql = "INSERT INTO Yourtable (Column1, Column2) VALUES (@Value1, @Value2)";

// Create the Command and Parameter objects.
SqlCommand cmd = new SqlCommand(sql, cn);

// Specify the parameter value.
cmd.Parameters.AddWithValue("@Value1", Textbox1.Text);
cmd.Parameters.AddWithValue("@Value2", Textbox2.Text);

// Execute the Query
cmd.ExecuteNonQuery();
}


Complete Code is given below
HTML:
<asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server" ScriptMode="Release">

</asp:ToolkitScriptManager>
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<asp:TabPanel ID="TabPanel1" runat="server" HeaderText="ChildPage1">
<ContentTemplate>
<%--Your other Controls Here--%>
<asp:TextBox runat="server" ID="Textbox1">
</asp:TextBox>
<asp:TextBox runat="server" ID="Textbox2">
</asp:TextBox>
<asp:Button runat="server" ID="Secondtab" Text="SaveandProceedtoPanel2" OnClick="Secondtab_Click" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel2" runat="server" HeaderText="ChildPage2">
<ContentTemplate>
<%--Your other Controls Here--%>
<asp:Button runat="server" ID="Thirdtab" Text="SaveandProceedtoPanel3" OnClick="Thirdtab_Click" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel3" runat="server" HeaderText="ChildPage3">
<ContentTemplate>
<%--Your other Controls Here--%>
<asp:Button runat="server" ID="Fourthtab" Text="SaveandProceedtoPanel4" OnClick="Fourthtab_Click" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="TabPanel4" runat="server" HeaderText="ChildPage4">
<ContentTemplate>
<%--Your other Controls Here--%>
Final Tab
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>


C#:
protected void Secondtab_Click(object sender, EventArgs e)

{
//Create a using statement to house your connection
using (SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["YourConnectionStringValue"].ConnectionString))
{
// Open your connection
cn.Open();

// Provide the query string with a parameter placeholder.
// Here change the columnames and table names as per you table
string sql = "INSERT INTO Yourtable (Column1, Column2) VALUES (@Value1, @Value2)";

// Create the Command and Parameter objects.
SqlCommand cmd = new SqlCommand(sql, cn);

// Specify the parameter value.
cmd.Parameters.AddWithValue("@Value1", Textbox1.Text);
cmd.Parameters.AddWithValue("@Value2", Textbox2.Text);

// Execute the Query
cmd.ExecuteNonQuery();
}


// Proceed to Second Tab after saving the details
TabContainer1.ActiveTab = TabContainer1.Tabs[1];

}

protected void Thirdtab_Click(object sender, EventArgs e)
{
//Code to save the Details from Third tab here

// Proceed to Third Tab after saving the details
TabContainer1.ActiveTab = TabContainer1.Tabs[2];
}

protected void Fourthtab_Click(object sender, EventArgs e)
{
//Code to save the Details from Third tab here

// Proceed to Third Tab after saving the details
TabContainer1.ActiveTab = TabContainer1.Tabs[3];
}


Please mark my reply as answer if it answers your question

Thanks,
A2H
My Blog

Write2varun, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Write2varun on: 3/21/2014 [Member] Starter | Points: 25

Up
0
Down
Thanks for the reply but I cannot include two pages together i have two pages and I'm assessing them via a third page which include the tab feature

Write2varun, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response