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