保留在回发口令字段值 [英] Retain Password Field Value on PostBack
问题描述
现在我有一个asp:精灵3步
Right now I have an asp:Wizard with 3 Steps.
- 创建用户
- 表格到电子邮件
- 字段摘要
当被点击的第三步完成按钮,我想创建用户并发送的形式。我的逻辑是写,但我唯一的问题是pssed在向导时,下一步按钮是$ P $,发生回传,我的密码字段:
When the finish button is clicked on the third step I would like to Create the user and send the form. I have the logic for this written but the only problem I have is the when the next button is pressed on a wizard, a PostBack occurs and my password field:
<asp:TextBox ID="txtPassword" TextMode="Password" Width="70%" runat="server" />
不保留其值。
什么你会建议将是最安全的,实用的方法让我克服这个问题?
What would you suggest would be the most secure and practical method for me to overcome this problem?
推荐答案
我可能会开发一类重presenting将由向导创建的数据:
I would probably develop a class representing the data that will be created by the wizard:
public class WizardForm
{
public User NewUser {get;set;}
public Form FormToEmail {get;set;}
}
然后通过该向导的每一步我会更新这个类并将其存储在会话:
Then on each step through the wizard I'd update this class and store it in session:
WizardForm form = Session["WizardForm"] as WizardForm;
if (form == null)
{
form = new WizardForm();
Session["WizardForm"] = form;
}
form.User.Password = txtPassword.Text; // etc
或者你可以只存储在会话密码,以后检索:
Or you could just store the password in Session and retrieve it later:
Session["WizardPassword"] = txtPassword.Text;
string password = Session["WizardPassword"].ToString();
这篇关于保留在回发口令字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!