[英]ASP.net Wizard Control triggering Page_Load()
我正在寫一個頁面來收集用戶信息(姓名,地址,信用卡信息等)以進行結帳。 該頁面具有ASP.net向導控件,並假定用戶已登錄其網站用戶帳戶。 Page_Load()包含以下代碼:
// Get the user
MembershipUser user = Membership.GetUser(User.Identity.Name);
// Get the user's profile
ProfileCommon Profile = (ProfileCommon)ProfileCommon.Create(user.UserName);
FirstName.Text = Profile.FirstName;
LastName.Text = Profile.LastName;
OrganizationName.Text = Profile.OrganizationName;
Address1.Text = Profile.Address1;
Address2.Text = Profile.Address2;
City.Text = Profile.City;
State.Text = Profile.State;
ZipCode.Text = Profile.ZipCode;
Country.Text = Profile.Country;
Telephone.Text = Profile.Telephone;
Fax.Text = Profile.Fax;
Email.Text = user.Email;
這樣就可以將用戶信息成功加載到向導的第一步中。 但是,如果用戶更改了任何文本框中的文本,然后單擊“下一步”轉到下一步,然后單擊“上一步”返回到第一步,則頁面將從Page_Load()重新加載用戶的信息。 有什么好的方法來防止這種行為並將更改后的文本保留在這些文本框中?
您正在使用ISpostback嗎? 如果(!IsPostBack){//頁面加載代碼在此處}
檢查IsPostBack。 這就是Web窗體的工作方式。 每次點擊都會調用Page_Load()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.