PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/BlogEngine/BlogEngine.NET/admin/Settings/Email.aspx

#
ASP.NET | 136 lines | 127 code | 9 blank | 0 comment | 3 complexity | 81d10cf6ee6a180810b5f4233fe03bec MD5 | raw file
  1<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.master" AutoEventWireup="true" CodeFile="Email.aspx.cs" Inherits="admin.Settings.Email" %>
  2<%@ Register src="Menu.ascx" tagname="TabMenu" tagprefix="menu" %>
  3
  4<asp:Content ID="Content1" ContentPlaceHolderID="cphAdmin" Runat="Server"> 
  5    <script type="text/javascript">
  6        $(document).ready(function () {
  7            var	frm	= document.forms.aspnetForm;
  8            $(frm).validate({
  9                onsubmit: false
 10            });
 11
 12            $("#btnSave").click(function (evt) {
 13                if ($(frm).valid())
 14                    SaveSettings();
 15                
 16                evt.preventDefault();
 17            });
 18        });
 19        function SaveSettings() {
 20            $('.loader').show();
 21		
 22            var dto = { 
 23				"email": $("[id$='_txtEmail']").val(),
 24				"smtpServer": $("[id$='_txtSmtpServer']").val(),
 25				"smtpServerPort": $("[id$='_txtSmtpServerPort']").val(),
 26				"smtpUserName": $("[id$='_txtSmtpUsername']").val(),
 27				"smtpPassword": $("[id$='_txtSmtpPassword']").val(),
 28				"sendMailOnComment": $("[id$='_cbComments']").attr('checked'),
 29				"enableSsl": $("[id$='_cbEnableSsl']").attr('checked'),
 30				"emailSubjectPrefix": $("[id$='_txtEmailSubjectPrefix']").val()
 31			};
 32			
 33            $.ajax({
 34                url: SiteVars.ApplicationRelativeWebRoot + "admin/Settings/Email.aspx/Save",
 35                type: "POST",
 36                dataType: "json",
 37                contentType: "application/json; charset=utf-8",
 38                data: JSON.stringify(dto),
 39                beforeSend: onAjaxBeforeSend,
 40                success: function (result) {
 41                    var rt = result.d;
 42                    if (rt.Success)
 43                        ShowStatus("success", rt.Message);
 44                    else
 45                        ShowStatus("warning", rt.Message);
 46                }
 47            });
 48            $('.loader').hide();
 49            return false;
 50        }
 51        function TestEmail() {
 52            $('.loader').show();
 53            var dto = {
 54                "email": $("[id$='_txtEmail']").val(),
 55                "smtpServer": $("[id$='_txtSmtpServer']").val(),
 56                "smtpServerPort": $("[id$='_txtSmtpServerPort']").val(),
 57                "smtpUserName": $("[id$='_txtSmtpUsername']").val(),
 58                "smtpPassword": $("[id$='_txtSmtpPassword']").val(),
 59                "sendMailOnComment": $("[id$='_cbComments']").attr('checked'),
 60                "enableSsl": $("[id$='_cbEnableSsl']").attr('checked'),
 61                "emailSubjectPrefix": $("[id$='_txtEmailSubjectPrefix']").val()
 62            };
 63
 64            $.ajax({
 65                url: SiteVars.ApplicationRelativeWebRoot + "admin/Settings/Email.aspx/TestSmtp",
 66                type: "POST",
 67                dataType: "json",
 68                contentType: "application/json; charset=utf-8",
 69                data: JSON.stringify(dto),
 70                beforeSend: onAjaxBeforeSend,
 71                success: function (result) {
 72                    var rt = result.d;
 73                    if (rt.Success)
 74                        ShowStatus("success", rt.Message);
 75                    else
 76                        ShowStatus("warning", rt.Message);
 77                }
 78            });
 79            $('.loader').hide();
 80            return false;
 81        } 
 82    </script>
 83     
 84	<div class="content-box-outer">
 85		<div class="content-box-right">
 86			<menu:TabMenu ID="TabMenu" runat="server" />
 87		</div>
 88		<div class="content-box-left">
 89        <h1><%=Resources.labels.settings %></h1>
 90
 91                <ul class="fl leftaligned">
 92                    <li>
 93                        <label class="lbl" for="<%=txtEmail.ClientID %>"><%=Resources.labels.emailAddress %></label>
 94                        <asp:TextBox CssClass="w300 email" runat="server" ID="txtEmail" />
 95                    </li>
 96                    <li>
 97                        <label class="lbl" for="<%=txtSmtpServer.ClientID %>"><%=Resources.labels.smtpServer%></label>
 98                        <asp:TextBox runat="server" ID="txtSmtpServer" CssClass="w300" />
 99                    </li>
100                    <li>
101                        <label class="lbl" for="<%=txtSmtpServerPort.ClientID %>"><%=Resources.labels.portNumber %></label>
102                        <asp:TextBox runat="server" ID="txtSmtpServerPort" Width="35" CssClass="number" />
103                        <span class="belowHelp"><%=Resources.labels.portNumberDescription %></span>
104                    </li>
105                    <li>
106                        <label class="lbl" for="<%=txtSmtpUsername.ClientID %>"><%=Resources.labels.userName %></label>
107                        <asp:TextBox CssClass="txt" runat="server" ID="txtSmtpUsername" Width="300" />
108                    </li>
109                    <li>
110                        <label class="lbl" for="<%=txtSmtpPassword.ClientID %>"><%=Resources.labels.password %></label>
111                        <asp:TextBox TextMode="Password"  runat="server" ID="txtSmtpPassword" Width="300" />
112                    </li>
113                    <li>
114                        <label class="lbl" for="<%=txtEmailSubjectPrefix.ClientID %>"><%=Resources.labels.emailSubjectPrefix %></label>
115                        <asp:TextBox runat="server" ID="txtEmailSubjectPrefix" Width="300" />
116                    </li>
117                    <li>
118                        <label class="lbl"><%=Resources.labels.otherSettings %></label>
119                        <asp:CheckBox runat="Server" ID="cbEnableSsl" />
120                        <label for="<%=cbEnableSsl.ClientID %>"><%=Resources.labels.enableSsl%></label>
121                    </li>
122                    <li>
123                        <span class="filler"></span>
124                        <asp:CheckBox runat="Server" ID="cbComments" />
125                        <label for="<%=cbComments.ClientID %>"><%=Resources.labels.sendCommentEmail %></label>
126                    </li>
127                </ul>
128            <div class="action_buttons">
129                <input type="submit" id="btnSave" class="btn primary" value="<%=Resources.labels.saveSettings %>" />
130                <input type="submit" class="btn" value="<%=Resources.labels.testEmailSettings %>" onclick="return TestEmail();" />
131                <asp:Label runat="Server" ID="lbSmtpStatus" />
132            </div>
133        </div>
134    </div>
135</asp:Content>
136