-3

这段代码有问题吗?一晚上都想不通!

protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
{
    string email2 = Membership.GetUser(User.Identity.Name).Email;
    MembershipUser currentUser = Membership.GetUser();
    string UserId2 = currentUser.ProviderUserKey.ToString();
    TextBox2.Text = email2;
    TextBox3.Text = UserId2;
}

它说必须有返回类型。

4

2 回答 2

8

脑海中浮现三件事:

  • 您没有该方法的左大括号
  • 您的If陈述应该是if- C# 区分大小写
  • 您没有该方法的右括号。
于 2012-09-13T03:13:03.683 回答
3

尝试这个:

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        string email2 = Membership.GetUser(User.Identity.Name).Email;
        MembershipUser currentUser = Membership.GetUser();
        string UserId2 = currentUser.ProviderUserKey.ToString();

        TextBox2.Text = email2;
        TextBox3.Text = UserId2;

    }
}
于 2012-09-13T03:15:16.180 回答