问题描述
我在婚姻门户网站工作,有7个注册步骤,例如:个人详细信息,身体属性,家庭详细信息,教育详细信息等每个都有下一个按钮,直到最后一个,即祝贺页。
现在我想知道如何将变量从一个表单移动到另一个表单在哪里以及如何在最后一个页面按钮事件或每个提交按钮上实现插入命令。
但是我想在一个表中插入所有字段,即注册表。
I am working on marriage portal and there are 7 steps for registration e.g. personal details, physical attributes, family details, educational detail etc. each having next button till last one i.e. congratulation page.
now i want to know that how to move variables from one form to another form where and how implement insert command either on last last page button event or at each submit button.
but i want to insert all the fields in one table i.e. registration table.
推荐答案
有很多方法可以将值从一个页面传递到另一个页面。
您可以通过 Querystring 或者你可以使用 Session 。
您只需要根据您的逻辑需要进行管理,并在使用后将全部作为安全目的进行处理。
There are many way to pass the value from one page to another.
You can pass value through Querystring or you can use Session for the same.
You only need to Manage as your logical need and after use Dispose all as Security Purpose.
做一些谷歌简单
乐于助人!!!
Do some Google its Simple
Happy to help!!!
<input type="hidden" id="hiddenPersonalDetails" runat="server" />
<input type="hidden" id="hiddenEducationalDetails" runat="server" />
<asp:textbox id="txtName" runat="server" xmlns:asp="#unknown"></asp:textbox>
<asp:textbox id="txtEducation" runat="server" xmlns:asp="#unknown"></asp:textbox>
点击提交按钮点击:
On Submit button click:
protected void btnSubmit_Click(object sender, EventArgs e)
{
hiddenPersonalDetails.Value=txtName.Text;
hiddenEducationalDetails.Value=txtEducation.Text;
}
下面的代码可以帮助您在数据库中插入记录
Below code might help you to insert the records in the DB
string personalDetails=hiddenPersonalDetails.Value;
string educationalDetails=hiddenEducationalDetails.Value;
string connectionString = "Your connection string";
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "INSERT INTO dbo.table(PersonalDetails, EducationalDetails) VALUES (@personalDetails, @educationalDetails)";
command.Parameters.AddWithValue("@personalDetails", personalDetails);
command.Parameters.AddWithValue("@educationalDetails",educationalDetails);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
问候
Anurag
Regards
Anurag
这篇关于将变量从一个表单移动到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!