|
This example sends an email when a button is clicked in a generated application. The easiest
way to implement this is to override the Button_Click() method in the TableControl class.
Step 1: Using the Application Wizard in Iron Speed Designer, create a set of application
pages using a database table such as the Orders table in the Northwind database.
Step 2: Drag a button from the Iron Speed Designer tool box onto the ShowOrdersTablePage.aspx
page. Place it next to the Export button in the Orders table panel.
Step 3: Go to Tools, Page Properties. Select the newly added button and set the following
properties.
| Tab |
Property |
Setting |
| Display |
Button tex |
myButton |
| Bindings |
Button Command |
Custom |
| Bindings |
Enable client-side validation |
On (checked) |
Step 4: Override the Button_Click() method in the OrdersTableControl class, located in:
.NET Framework 1.1:
|
...\<Application Folder>\Orders\ShowOrdersTablePage.Controls.cs or .vb
|
.NET Framework 2.0:
|
...\<Application Folder>\App_Code\Orders\ShowOrdersTablePage.Controls.cs or .vbb
|
C#:
public override void Button_Click(object sender, EventArgs args)
{
try
{
BaseClasses.Utils.MailSender email = new BaseClasses.Utils.MailSender();
email.AddFrom("fromAddress@company.com");
email.AddTo("toAddress@company.com");
email.AddBCC("bccAddress@company.com");
email.SetSubject("Confirmation");
email.SetContent("Thank you for your request");
email.SendMessage();
}
catch (System.Exception ex)
{
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "UNIQUE_SCRIPTKEY", ex.Message);
}
}
|
Visual Basic .NET:
Public Overrides Sub Button_Click(ByVal sender As Object, ByVal args As EventArgs)
Try
Dim email As BaseClasses.Utils.MailSender = New BaseClasses.Utils.MailSender
email.AddFrom("fromAddress@company.com")
email.AddTo("toAddress@company.com")
email.AddBCC("bccAddress@company.com")
email.SetSubject("Confirmation")
email.SetContent("Thank you for your request")
email.SendMessage()
Catch ex As Exception
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY", ex.Message)
End Try
End Sub
|
Step 4: You may need to configure your email server authentication to accept emails sent
from your application program. See "Configuring Email Server Authentication" in the online help for details.
|