For the benefit of VB users I have converted your user control and also added 5 extra fields.I also removed the Form tag as my master has this already declared.
EmailForm.ascx
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="EmailForm.ascx.vb" Inherits="Nine9.EmailForm" %>
Public Class EmailForm Inherits System.Web.UI.UserControl
Dim m_ThankYouPageId As Integer Dim m_Recipients, m_Sender, m_ButtonText, m_Subject, m_Field1_Name, m_Field1_MandatoryMessage, _ m_Field2_Name, m_Field2_MandatoryMessage, m_Field3_Name, m_Field3_MandatoryMessage, _ m_Field4_Name, m_Field4_MandatoryMessage, m_Field5_Name, m_Field5_MandatoryMessage, _ m_Field6_Name, m_Field6_MandatoryMessage, m_Field7_Name, m_Field7_MandatoryMessage, _ m_Field8_Name, m_Field8_MandatoryMessage, m_Field9_Name, m_Field9_MandatoryMessage, _ m_Field10_Name, m_Field10_MandatoryMessage As String
Dim m_Field1_LargeText, m_Field2_LargeText, m_Field3_LargeText, m_Field4_LargeText, m_Field5_LargeText, _ m_Field6_LargeText, m_Field7_LargeText, m_Field8_LargeText, m_Field9_LargeText, m_Field10_LargeText As Boolean
Public Property ThankYouPageId() As Integer Get Return m_ThankYouPageId End Get Set(ByVal value As Integer) m_ThankYouPageId = value End Set End Property
Public Property Recipients() As String Get Return m_Recipients End Get Set(ByVal value As String) m_Recipients = value End Set End Property
Public Property Sender() As String Get Return m_Sender End Get Set(ByVal value As String) m_Sender = value End Set End Property
Public Property ButtonText() As String Get Return m_ButtonText End Get Set(ByVal value As String) m_ButtonText = value End Set End Property
Public Property Subject() As String Get Return m_Subject End Get Set(ByVal value As String) m_Subject = value End Set End Property
Public Property Field1_Name() As String Get Return m_Field1_Name End Get Set(ByVal value As String) m_Field1_Name = value End Set End Property
Public Property Field1_MandatoryMessage() As String Get Return m_Field1_MandatoryMessage End Get Set(ByVal value As String) m_Field1_MandatoryMessage = value End Set End Property
Public Property Field1_LargeText() As Boolean Get Return m_Field1_LargeText End Get Set(ByVal value As Boolean) m_Field1_LargeText = value End Set End Property
Public Property Field2_Name() As String Get Return m_Field2_Name End Get Set(ByVal value As String) m_Field2_Name = value End Set End Property
Public Property Field2_MandatoryMessage() As String Get Return m_Field2_MandatoryMessage End Get Set(ByVal value As String) m_Field2_MandatoryMessage = value End Set End Property
Public Property Field2_LargeText() As Boolean Get Return m_Field2_LargeText End Get Set(ByVal value As Boolean) m_Field2_LargeText = value End Set End Property
Public Property Field3_Name() As String Get Return m_Field3_Name End Get Set(ByVal value As String) m_Field3_Name = value End Set End Property
Public Property Field3_MandatoryMessage() As String Get Return m_Field3_MandatoryMessage End Get Set(ByVal value As String) m_Field3_MandatoryMessage = value End Set End Property
Public Property Field3_LargeText() As Boolean Get Return m_Field3_LargeText End Get Set(ByVal value As Boolean) m_Field3_LargeText = value End Set End Property
Public Property Field4_Name() As String Get Return m_Field4_Name End Get Set(ByVal value As String) m_Field4_Name = value End Set End Property
Public Property Field4_MandatoryMessage() As String Get Return m_Field4_MandatoryMessage End Get Set(ByVal value As String) m_Field4_MandatoryMessage = value End Set End Property
Public Property Field4_LargeText() As Boolean Get Return m_Field4_LargeText End Get Set(ByVal value As Boolean) m_Field4_LargeText = value End Set End Property
Public Property Field5_Name() As String Get Return m_Field5_Name End Get Set(ByVal value As String) m_Field5_Name = value End Set End Property
Public Property Field5_MandatoryMessage() As String Get Return m_Field5_MandatoryMessage End Get Set(ByVal value As String) m_Field5_MandatoryMessage = value End Set End Property
Public Property Field5_LargeText() As Boolean Get Return m_Field5_LargeText End Get Set(ByVal value As Boolean) m_Field5_LargeText = value End Set End Property
Public Property Field6_Name() As String Get Return m_Field6_Name End Get Set(ByVal value As String) m_Field6_Name = value End Set End Property
Public Property Field6_MandatoryMessage() As String Get Return m_Field6_MandatoryMessage End Get Set(ByVal value As String) m_Field6_MandatoryMessage = value End Set End Property
Public Property Field6_LargeText() As Boolean Get Return m_Field6_LargeText End Get Set(ByVal value As Boolean) m_Field6_LargeText = value End Set End Property
Public Property Field7_Name() As String Get Return m_Field7_Name End Get Set(ByVal value As String) m_Field7_Name = value End Set End Property
Public Property Field7_MandatoryMessage() As String Get Return m_Field7_MandatoryMessage End Get Set(ByVal value As String) m_Field7_MandatoryMessage = value End Set End Property
Public Property Field7_LargeText() As Boolean Get Return m_Field7_LargeText End Get Set(ByVal value As Boolean) m_Field7_LargeText = value End Set End Property
Public Property Field8_Name() As String Get Return m_Field8_Name End Get Set(ByVal value As String) m_Field8_Name = value End Set End Property
Public Property Field8_MandatoryMessage() As String Get Return m_Field8_MandatoryMessage End Get Set(ByVal value As String) m_Field8_MandatoryMessage = value End Set End Property
Public Property Field8_LargeText() As Boolean Get Return m_Field8_LargeText End Get Set(ByVal value As Boolean) m_Field8_LargeText = value End Set End Property
Public Property Field9_Name() As String Get Return m_Field9_Name End Get Set(ByVal value As String) m_Field9_Name = value End Set End Property
Public Property Field9_MandatoryMessage() As String Get Return m_Field9_MandatoryMessage End Get Set(ByVal value As String) m_Field9_MandatoryMessage = value End Set End Property
Public Property Field9_LargeText() As Boolean Get Return m_Field9_LargeText End Get Set(ByVal value As Boolean) m_Field9_LargeText = value End Set End Property
Public Property Field10_Name() As String Get Return m_Field10_Name End Get Set(ByVal value As String) m_Field10_Name = value End Set End Property
Public Property Field10_MandatoryMessage() As String Get Return m_Field10_MandatoryMessage End Get Set(ByVal value As String) m_Field10_MandatoryMessage = value End Set End Property
Public Property Field10_LargeText() As Boolean Get Return m_Field10_LargeText End Get Set(ByVal value As Boolean) m_Field10_LargeText = value End Set End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load m_submitButton.Text = ButtonText
Protected Overrides Sub OnInit(ByVal e As EventArgs) MyBase.OnInit(e) AddHandler m_submitButton.Click, AddressOf m_submitButton_Click
End Sub
Private Sub InitialiseFields(ByVal label As Label, ByVal textArea As TextBox, ByVal validator As RequiredFieldValidator, ByVal name As String, ByVal largeText As Boolean, ByVal mandatoryMessage As String) label.Text = name
If largeText Then textArea.TextMode = TextBoxMode.MultiLine End If
validator.Text = mandatoryMessage validator.Enabled = Not [String].IsNullOrEmpty(mandatoryMessage) End Sub Protected Sub m_submitButton_Click(ByVal sender__1 As Object, ByVal e As EventArgs) Page.Validate()
If Page.IsValid Then Dim message As New MailMessage() message.From = New MailAddress(Sender.Replace(vbLf, "").Replace(vbCr, ""))
For Each recipeient As String In Recipients.Replace(vbLf, "").Replace(vbCr, "").Split(";"c) message.[To].Add(New MailAddress(recipeient)) Next
Dim body As String = "The following details were submitted to your website" & Environment.NewLine & Environment.NewLine
body += GetFieldValue(m_label1, m_textArea1) body += GetFieldValue(m_label2, m_textArea2) body += GetFieldValue(m_label3, m_textArea3) body += GetFieldValue(m_label4, m_textArea4) body += GetFieldValue(m_label5, m_textArea5) body += GetFieldValue(m_label6, m_textArea6) body += GetFieldValue(m_label7, m_textArea7) body += GetFieldValue(m_label8, m_textArea8) body += GetFieldValue(m_label9, m_textArea9) body += GetFieldValue(m_label10, m_textArea10)
Dim smtpClient As New SmtpClient() smtpClient.Send(message)
' Redirect If ThankYouPageId > 0 Then Context.Response.Redirect(umbraco.library.NiceUrl(ThankYouPageId), True) Else Context.Response.Redirect("/") End If End If End Sub
Private Function GetFieldValue(ByVal label As Label, ByVal textArea As TextBox) As String If Not [String].IsNullOrEmpty(label.Text) Then Return label.Text & ": " & textArea.Text & Environment.NewLine Else Return "" End If End Function
Protected Overrides Sub OnPreRender(ByVal e As EventArgs) MyBase.OnPreRender(e)
Email Form Code Behind
I wondered if I could have the code behind file for the Email form.
I'd like to make some changes and add some more field options.
I hope you can help.
regards.
I guess that's a no then.
Thanks anyway.
Sorry Streety, forgot to respond.
The full source is already available on the projects homepage in Koiak.StandardSite.rar
Enjoy!
Chris
Hi Chris,
Yes I have looked there.
Just the BasicSiteInstall.ascx and Login.ascx are present.
Is it not under the usercontrols directory?
regards
Ah no problem, I'll upload a new version of the code tonight
Would appreciate it.
I just need to mod it to accept 7 fields instead of 5 so I need the code behind.
Ta
Apologies, I keep forgetting to upload this. I'll definately do it tonight.
Chris
This has now been uploaded.
Cheers
Thanks for that Chris.
Have got it.
For the benefit of VB users I have converted your user control and also added 5 extra fields.I also removed the Form tag as my master has this already declared.
EmailForm.ascx
EmailForm.ascx.vb
hi
could you upload the code behind file of the Login.ascx.cs
i need to modify in the LoginButton_Click function in the login.ascx.cs
adarsh,
Please do not cross post. I have already answered this http://our.umbraco.org/projects/starter-kits/standard-website/general/18262-login-Form-for-codebehind
Chris
Hi sorry chris.
is working on a reply...