PasswordRecovery无法正常支持中文的幕后黑手----ResponseEncoding

来源:互联网 发布:网络客服销售话术 编辑:程序博客网 时间:2024/04/28 09:57

 最近开发的系统中引用了微软的用户提供程序,由于是第一次使用这个提供程序,碰到的问题也不接连不断,现在把其中的最顽固的家伙搬出来与大家分享,希望大家以后遇到类似问题不再花很多时间。

PasswordRecovery控件是NET提供的密码找回控件,但最近用的时候却发现他居然不支持,中文!

如果输入的用户名或提示答案是中文的话,触发提交事件后将返回乱码(输入的中文),或干脆数据直接丢失,导致控件提示数据没输入。(情况和我上传的图片一个样)

我就不信了,难道我人品这么差么,人家都可以正常使用怎么到我手上就不行了哩。

那我就自己写个吧,在用户提供程序上扩展个自己的密码找回控件。。。

哎。。控件写好后高兴的放上去后出现的问题居然一样。。。。狂汗。。。

仔细一找,原来黑手决然是@Page指令中的ResponseEncoding属性惹的祸,当场吐血。。。。

 

顺便把我自己写的密码找回用户控件帖出来。。(真是作弄人呀。。)

  1. <%@ Control Language="C#" AutoEventWireup="true" CodeFile="GetPwd.ascx.cs" Inherits="fore_AccountControl_GetPwd"%>
  2. <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" OnNextButtonClick="Wizard1_NextButtonClick" StepNextButtonText="下一步2" Width="276px" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" OnFinishButtonClick="Wizard1_FinishButtonClick">
  3.             <WizardSteps>
  4.                 <asp:WizardStep ID="WizardStep1" runat="server" AllowReturn="False" Title=" ">
  5.                      <asp:Label ID="Label1" runat="server" Text="用户名"></asp:Label>
  6.                     <asp:TextBox ID="TextBox4" runat="server" Width="100px"></asp:TextBox>
  7.                    
  8.                 </asp:WizardStep>
  9.                 <asp:WizardStep ID="WizardStep2" runat="server" AllowReturn="False" Title=" ">
  10.                     <asp:Label ID="Label2" runat="server" Text="提示问题"></asp:Label>
  11.                     <asp:Label ID="Label3" runat="server"></asp:Label>
  12.                     <br />
  13.                     <asp:Label ID="Label4" runat="server" Text="提示答案"></asp:Label>
  14.                     <asp:TextBox ID="TextBox5" runat="server" Width="100px"></asp:TextBox>
  15.                 </asp:WizardStep>
  16.             </WizardSteps>
  17.             <StartNavigationTemplate>
  18.                 <asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="下一步" />
  19.             </StartNavigationTemplate>
  20.             <StepStyle Font-Size="0.8em" ForeColor="#333333" />
  21.             <SideBarStyle BackColor="#507CD1" Font-Size="0.9em" VerticalAlign="Top" />
  22.             <NavigationButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid"
  23.                 BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" />
  24.             <SideBarButtonStyle BackColor="#507CD1" Font-Names="Verdana" ForeColor="White" />
  25.             <HeaderStyle BackColor="#284E98" BorderColor="#EFF3FB" BorderStyle="Solid" BorderWidth="2px"
  26.                 Font-Bold="True" Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" />
  27.         </asp:Wizard>
  1.     protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
  2.     {
  3.         if (e.CurrentStepIndex == 0)
  4.         {
  5.             MembershipUser user = Membership.GetUser(TextBox4.Text);
  6.             if (user != null)
  7.             {
  8.                 Label3.Text = user.PasswordQuestion;
  9.             }
  10.             else
  11.             {
  12.              
  13.                 Page.ClientScript.RegisterStartupScript(this.GetType(), "message""alert('用户名不存在!')"true);
  14.                 e.Cancel = true;
  15.             }
  16.         }
  17.     }
  18.     protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
  19.     {
  20.         try
  21.         {
  22.             MembershipUser user = Membership.GetUser(TextBox4.Text);
  23.            
  24.             string pwd = user.GetPassword(TextBox5.Text);
  25.             
  26.             popdomManager.sendMail(pwd, user.Email);
  27.         }
  28.         catch
  29.         {
  30.             Page.ClientScript.RegisterStartupScript(this.GetType(), "message""alert('提示答案错误')"true);
  31.         }
  32.     }

哎。。不行了。。。