html代码:
...
邮箱地址:(如xxx@163.com)
<input id="txtUEmailAddress" runat="server" type="text" οnblur="changetext(this)" />
<table id="EMailDetail" name="EMailDetail" cellpadding="0" cellspacing="0">
<tr>
<td class="style2" align="right">
接收服务器地址:
</td>
<td>
<div style="height: 17px; text-align: center; vertical-align: bottom; width: 372px;">
<div style="float: left;">
<asp:TextBox ID="txtPop3Address" runat="server" Width="148px"></asp:TextBox></div>
<div style="float: left; margin-left: 10px; width: 65px; text-align: left;">
<asp:CheckBox ID="chkPopSsl" runat="server" Text="SSL加密" /></div>
<div style="float: Right; margin-top: 3px; width: 135px;">
(如:imap.xxx.com:993)</div>
</div>
</td>
</tr>
<tr>
<td class="style2" align="right">
接收服务器协议:
</td>
<td>
<asp:DropDownList ID="ddlPopProtocol" runat="server">
<asp:ListItem Value="1">IMap</asp:ListItem>
<asp:ListItem Value="2">Pop</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style2" align="right">
发送服务器地址:
</td>
<td>
<div style="float: left;">
<asp:TextBox ID="txtSmtpAddress" runat="server" Width="148px"></asp:TextBox></div>
<div style="float: left; width: 65px; margin-left: 10px; text-align: left;">
<asp:CheckBox ID="chkSmtp" runat="server" Text="SSL加密" /></div>
</td>
</tr>
<tr>
<td class="style2" align="right">
发送服务器协议:
</td>
<td>
<asp:DropDownList ID="ddlSmtpProtocol" runat="server">
<asp:ListItem Value="1">SMTP</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
...
javascript代码:
<script type="text/javascript">
获取请求中德querystring参数
function QueryString(fieldName) {
var urlString = document.location.search;
if (urlString != null) {
var typeQu = fieldName + "=";
var urlEnd = urlString.indexOf(typeQu);
if (urlEnd != -1) {
var paramsUrl = urlString.substring(urlEnd + typeQu.length);
var isEnd = paramsUrl.indexOf('&');
if (isEnd != -1) {
return paramsUrl.substring(0, isEnd);
}
else {
return paramsUrl;
}
}
else {
return null;
}
}
else {
return null;
}
}
//界面初始化
$(document).ready(function () {
$("#EMailDetail").hide();
changetext($("#txtUEmailAddress")[0]);
});
function changetext(obj) {
var actiontype = QueryString("type");
var entUserID = QueryString("entUserID");
if (obj.value == "") {
$("#lblEntUserMsg").val("邮件地址不能为空!");
$("#lblEntUserMsg").focus();
return;
}
$.get("mailExist.ashx?strEMailAddr=" + obj.value + "&type=" + actiontype + "&entUserID=" + entUserID, function (data) {
var args = data.toString().split("|");
var Exist = args[0].split("=")[1];
var Show = args[1].split("=")[1];
if (Show == "true") {
$("#EMailDetail").show();
}
else {
$("#EMailDetail").hide();
$("#txtPop3Address").val("");
$("#txtSmtpAddress").val("");
}
if (Exist == "true") {
$("#lblEntUserMsg").text("邮件地址已经存在!");
}
else {
$("#lblEntUserMsg").text("");
}
});
}
</script>
mailExist.ashx文件:
//主要函数
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
StringBuilder strresult = new StringBuilder();
string strEMailAddr = context.Request.QueryString["strEMailAddr"].ToString();
string strType = context.Request.QueryString["type"].ToString();
string strEntUserID = context.Request.QueryString["entUserID"].ToString();
UserEmailBLL uebll = new UserEmailBLL();
if (strType == "modify")
{
//修改
int iEntUserID = Convert.ToInt32(strEntUserID);
int ret = uebll.GetNumberExceptSelf(iEntUserID, strEMailAddr);
if (ret != 0)
{
strresult.Append("Exist=true");
}
else
{
strresult.Append("Exist=false");
}
}
else
{
//添加
UserEmailInfo info = uebll.GetInfoByEmail(strEMailAddr);
if (info != null)
{
strresult.Append("Exist=true");
}
else
{
strresult.Append("Exist=false");
}
}
//是否是默认的邮件配置,如果是自定义界面不用展开,否则展开供用户输入
MailDoMainConfigBLL bll = new MailDoMainConfigBLL();
int idx = strEMailAddr.IndexOf('@');
if (idx > 0)
{
string strDomain = strEMailAddr.Substring(idx + 1);
MailDoMainConfigInfo configinfo = bll.GetByDomain(strDomain);
if (configinfo == null)
{
strresult.Append("|Show=true");
}
else
{
strresult.Append("|Show=false");
}
} context.Response.Write(strresult.ToString());
}