将变量从一个表单移动到另一个表单 [英] Move variables from one form to another form

查看:76
本文介绍了将变量从一个表单移动到另一个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在婚姻门户网站工作,有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.

推荐答案

使用多视图和查看概念所有细节,如个人详细信息,物理属性,家庭详细信息,教育详细信息放在单独的视图中,很容易以一种形式提交所有细节
use multiview and view concept all details like personal details, physical attributes, family details, educational detail put in separate view that's easy to submit all details in one form


嗨哥们





Hi buddy


Quote:

有很多方法可以将值从一个页面传递到另一个页面。

您可以通过<传递值b> 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!!!


嘿,



您可以根据您的要求使用会话变量,隐藏字段。

隐藏字段非常有用。

看看下面:



Hey,

You can use session variables, hidden fields based upon your requirement.
Hidden fields can be pretty useful.
Have a look below:

<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


这篇关于将变量从一个表单移动到另一个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆