?? lyrisexample2.ascx
字號:
<%@ Control language="c#" Inherits="Rainbow.DesktopModules.OneFileModule" %>
<%@ Register TagPrefix="cc1" Namespace="Rainbow.UI.WebControls" Assembly="Rainbow" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ Import Namespace="Rainbow.UI" %>
<%@ Import Namespace="Rainbow.UI.WebControls" %>
<%@ Import Namespace="Esperantus" %>
<%@ Import Namespace="Rainbow.Configuration" %>
<script language="C#" runat="server">
string lyrisListName;
string lyrisServerName;
void Page_Load(Object sender, EventArgs e)
{
InitSettings(SettingsType.Str);
// Note you have these variables available everywhere in your code:
// string SettingsStr -- The content of setting "Settings string"
// bool DebugMode -- true if setting "Debug Mode" is clicked
// bool SettingsExists -- false if settings are missing
// string GetStrSetting(settingName) -- Returns the setting from SettingsStr
// string GetXmlSetting(settingName) -- Returns the setting from XML file
// string GetSetting(settingName) -- Returns the setting in search order:
// 1)SettingsStr, 2)XML file
if (SettingsExists)
{
lyrisListName = GetSetting("LyrisListName");
lyrisServerName = GetSetting("LyrisServerName");
if (DebugMode)
Message.Text = "Debug info: " + lyrisListName + " - " + lyrisServerName;
}
if (IsPostBack == false)
{
// prepopulate box
email.Text = PortalSettings.CurrentUser.Identity.Email;
}
}
void SubscribeBtn_Click(Object sender, EventArgs e) {
JoinList(email.Text, lyrisListName);
Message.Text = email.Text + " subscribed!";
}
void LeaveBtn_Click(Object sender, EventArgs e) {
LeaveList(email.Text, lyrisListName);
Message.Text = email.Text + " unsubscribed!";
}
void JoinList(string email, string listname) {
MailMessage Mailer = new MailMessage();
Mailer.From = email;
Mailer.To = "join-" + listname + lyrisServerName;
Mailer.Subject = "Join";
Mailer.Body = "Join";
SmtpMail.SmtpServer = PortalSettings.SmtpServer;
SmtpMail.Send(Mailer);
}
void LeaveList(string email, string listname) {
MailMessage Mailer = new MailMessage();
Mailer.From = email;
Mailer.To = "leave-" + listname + lyrisServerName;
Mailer.Subject = "Leave";
Mailer.Body = "Leave";
SmtpMail.SmtpServer = PortalSettings.SmtpServer;
SmtpMail.Send(Mailer);
}
</script>
<cc1:DesktopModuleTitle EditText="Edit" EditUrl="~/DesktopModules/PropertyPage.aspx" PropertiesText="PROPERTIES" PropertiesUrl="~/DesktopModules/PropertyPage.aspx" runat="server" ID="ModuleTitle" />
<hr noshade="noshade" size="1pt" width="98%" />
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="SubSubHead" style="height:20">Newsletter Signup:</span></td>
</tr>
<tr>
<td>
<span class="Normal">Email:</span></td>
</td>
</tr>
<tr>
<td>
<asp:TextBox id="email" columns="9" width="130" cssclass="NormalTextBox" runat="server" />
<div class="SubHead">
<asp:RegularExpressionValidator runat="server" id="validEMailRegExp" ControlToValidate="email" Display="Dynamic" ErrorMessage="Please enter a valid email address." ValidationExpression="[\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+" />
<asp:RequiredFieldValidator runat="server" id="rfvEMail" ControlToValidate="email" Display="Dynamic" ErrorMessage="'Email' must not be left blank." />
</div>
</td>
</tr>
<tr>
<td>
<asp:Button id="SubscribeBtn" runat="server" OnClick="SubscribeBtn_Click" Text="Join" />
<asp:Button id="LeaveBtn" runat="server" OnClick="LeaveBtn_Click" Text="Leave" />
</td>
</tr>
<tr>
<td>
<asp:label id="Message" class="NormalRed" runat="server" />
</td>
</tr>
</table>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -