我这个小白又来了我为所做的SharePoint网站配置了基于SQL的表单验证。之后按照网上的一个贴子做了一个注册界面,经过测试时可以注册成功的,但是我想实现在用户注册的同时将注册信息以邮件的形式发到注册邮箱及管理员的邮箱,但是自行加了一段代码后,没有实现,而且注册网页出现错误。这里注册用户用的是CreateUserWizard控件,发邮件是用这个控件自带的一个属性。
代码如下:
<%@ Assembly Name="Microsoft.SharePoint.IdentityModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>
<%@ Page Language="C#" MasterPageFile="~/_layouts/simple.master" %>
<%@ Import Namespace="Microsoft.SharePoint.WebControls" %>
<%@ Register Tagprefix="SharePoint"
Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities"
Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.Administration" %>
<%@ Import Namespace="Microsoft.SharePoint.Administration.Claims" %>
<%@ Import Namespace="System.IdentityModel.Tokens" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<script language="C#" runat="server">
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('注册成功,请重新登陆');window.location='http://hypcgcb/_forms/default.aspx?ReturnUrl=%2f_layouts%2f15%2fAuthenticate.aspx%3fSource%3d%252FSitePages%252F%25E4%25B8%25BB%25E9%25A1%25B5%252Easpx%253FAjaxDelta%253D1%2526isStartPlt1%253D1355914005929&Source=%2FSitePages%2F%e4%b8%bb%e9%a1%b5.aspx%3FAjaxDelta%3D1%26isStartPlt1%3D1355914005929';", true);
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
用户注册界面
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
<!--Sign Up-->
华部
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderId="PlaceHolderSiteName" runat="server"/>
<asp:Content ID="Content4" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<asp:CreateUserWizard ID="SignUp" runat="server" LoginCreatedUser="false" oncreateduser="CreateUserWizard1_CreatedUser"
CreateUserButtonText="注 册">
<!--下面是为了发邮件添加的-->
<MailDefinition
BodyFileName="~/mail.txt"
Priority="High"
From="[email protected]"
IsBodyHtml="true"
Subject="新用户注册通知!"
CC="[email protected]">
</MailDefinition>
<!--结束-->
</asp:CreateUserWizard>
</asp:Content>