Hello dear,,
I have a question about a new recorder on the site wants to enroll in a particular course who shall by clicking on the registration link .. Then enter the data via the registration code .. OK .. and then send the data to email The code works correctly .. but my question here .. How do I bring this session data for email?
Code as follows:
Schedule.aspx :
<div>
<asp:Label ID="LabelMSG" runat="server" CssClass="LabelRegMsg"></asp:Label>
<div style="height: auto;">
<table style="width: 70%; color: #555; text-align: left; margin-top: 70px; margin-left: 20px;">
<tr style="float: left">
<td style="direction: ltr; width: 139px">
<asp:Label ID="LabelEnName" runat="server" Text="Name" CssClass="LabelReg"></asp:Label>
</td>
<td class="style2" style="width: 20%">
<asp:TextBox ID="TextBoxEnglishName" runat="server" CssClass="txtInhousetraining"></asp:TextBox>
</td>
<td style="padding-left: 30px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ValidationGroup="A"
ControlToValidate="TextBoxEnglishName" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style5">
<asp:Label ID="LabelEmail" runat="server" Text="Email" CssClass="LabelReg"></asp:Label>
</td>
<td class="style1">
<asp:TextBox ID="TextBoxEmail" runat="server" CssClass="txtInhousetraining"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBoxEmail"
ErrorMessage="Format Email Error" ValidationGroup="A" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ValidationGroup="A"
ControlToValidate="TextBoxEmail" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style5">
<asp:Label ID="LabelCityName" runat="server" Text="City" CssClass="LabelReg"></asp:Label>
</td>
<td class="style9">
<asp:TextBox ID="TextBoxCityName" runat="server" CssClass="txtInhousetraining"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ValidationGroup="A"
ControlToValidate="TextBoxCityName" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style3">
<asp:Label ID="LabelCountry" runat="server" Text="Country" CssClass="LabelReg"></asp:Label>
</td>
<td class="style4">
<asp:DropDownList ID="DropDownListCountry" runat="server" CssClass="txtInhousetraining"
Height="30px">
</asp:DropDownList>
</td>
<td class="style8">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ValidationGroup="A"
ControlToValidate="DropDownListCountry" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style5">
<asp:Label ID="LabelPhone" runat="server" Text="Phone/Mobile" CssClass="LabelReg"></asp:Label>
</td>
<td class="style2">
<asp:TextBox ID="TextBoxPhone" runat="server" CssClass="txtInhousetraining"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ValidationGroup="A"
ControlToValidate="TextBoxPhone" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style3">
<asp:Label ID="Label1" runat="server" Text="Category" CssClass="LabelReg"></asp:Label>
</td>
<td class="style4">
<asp:DropDownList ID="DropDownListCategory" runat="server" CssClass="txtInhousetraining"
Height="30px">
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ValidationGroup="A"
ControlToValidate="DropDownListCategory" ErrorMessage="Required field"></asp:RequiredFieldValidator>
</td>
</tr>
<tr style="float: left">
<td class="style6" style="vertical-align: top">
<asp:Label ID="LabelMobile0" runat="server" Text="Message" CssClass="LabelReg"></asp:Label>
</td>
<td class="style7">
<asp:TextBox ID="TextComment" runat="server" Height="120px" TextMode="MultiLine"
Style="width: 500px; height: 160px; background-color: #ffffff; border: 1px solid #B9C0CF;
border-radius: 4px;"></asp:TextBox>
</td>
<td class="style7">
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<div style="-webkit-border-left-radius: 8px; border: 0px solid #808080; float: left;
margin: 0px; border-radius: 7px; width: 99%; padding-left: 4px;">
<div id="Div1" class="oddRow" style="width: 100%;">
<asp:Repeater ID="RepeaterCourse" runat="server">
<ItemTemplate>
<div style="width: 30%;">
<asp:Label ID="LabelEnglishName" runat="server" CssClass="LabelReg"><%# Eval("EnglishName")%></asp:Label>
</div>
<label id="CityCountry" style="float: left; margin-left: -15px; margin-right: 15px;
color: maroon; font-size: 13px; text-align: center; width: 20%; margin-top: 20px;">
<%# Eval("CityCountry")%></label>
<label id="StartCourse" style="float: left; color: maroon; font-size: 13px; width: 20%;
margin-left: 15px; margin-right: -13px; margin-top: 20px;">
<%# Eval("StartCourse", "{0:MMM dd, yyyy}")%></label>
<label id="EndCourse" style="float: left; color: maroon; font-size: 13px; width: 20%;
margin-top: 20px;">
<%# Eval("EndCourse", "{0:MMM dd, yyyy}")%></label>
<label id="Days" style="float: left; width: 20%; margin-top: 20px;">
<%# Eval("Days")%></label>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
</div>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr style="float: left">
<td class="style6">
</td>
<td class="style7">
<asp:Button ID="ButtonSubmit" runat="server" Text="Submit" ValidationGroup="A" CssClass="buttonReg"
Style="cursor: pointer; background-color: #ffffff; color: #555; border: 1px solid #B9C0CF;" />
</td>
<td class="style7">
</td>
</tr>
</table>
</div>
</div>
VB.Net Code
Imports System.Net.Mail
Imports System.Data
Imports System.IO
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class CTRL_RegisterNew
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim objC As New Country
Dim dt As DataTable = objC.Find()
Dim dr As DataRow = dt.NewRow()
dr("CountryID") = 0
dr("CountryName") = " -- Select Country -- "
dt.Rows.InsertAt(dr, 0)
DropDownListCountry.DataSource = dt
DropDownListCountry.DataTextField = "CountryName"
DropDownListCountry.DataValueField = "CountryID"
DropDownListCountry.DataBind()
End If
If Not IsPostBack Then
Dim ObjC As New Category
Dim dt As DataTable = ObjC.Find()
Dim dr As DataRow = dt.NewRow()
dr("CategoryID") = 0
dr("CategoryName") = "--- All Courses ---"
dt.Rows.InsertAt(dr, 0)
DropDownListCategory.DataSource = dt
DropDownListCategory.DataTextField = "CategoryName"
DropDownListCategory.DataValueField = "CategoryID"
DropDownListCategory.DataBind()
End If
End Sub
Protected Sub ButtonSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSubmit.Click
Dim body As String = "Email: " + TextBoxEmail.Text + "<br>" + "Name: " + TextBoxEnglishName.Text + "<br>" + "Country: " + DropDownListCountry.SelectedItem.ToString + "<br>" + "City: " + TextBoxCityName.Text + "<br>" + "Phone: " + TextBoxPhone.Text + "<br>" + "Category: " + DropDownListCategory.SelectedValue + "<br>" + "<br>" + "<br>" + "Message: " + TextComment.Text + "<br>" + Eval("Englishname")
Dim mail As New System.Net.Mail.MailMessage()
mail.[To].Add("noor@gmail.com")
mail.Bcc.Add("noor@gmail.com")
mail.From = New MailAddress("noor@gmail.com")
mail.Subject = "From Inhouse Training ....By "
mail.Body = body
mail.IsBodyHtml = True
Dim smtp As New SmtpClient("relay-hosting.secureserver.net")
smtp.EnableSsl = False
smtp.UseDefaultCredentials = True
smtp.Send(mail)
LabelMSG.Text = "Sent Successfully"
ClearFields()
End Sub
Private Sub ClearFields()
TextBoxEnglishName.Text = ""
TextBoxEmail.Text = ""
DropDownListCountry.SelectedValue = 0
TextBoxCityName.Text = ""
TextBoxPhone.Text = ""
TextComment.Text = ""
DropDownListCategory.SelectedValue = 0
End Sub
End Class
VB Code
Public Function FindCourse() As DataTable
GetConnection()
Dim SQL As String = "SELECT DISTINCT ScheduleNew.ScheduleID, ScheduleNew.CourseID , ScheduleNew.CityID, ScheduleNew.StartCourse, ScheduleNew.EndCourse, ScheduleNew.Days, ScheduleNew.CountryID, ScheduleNew.CategoryID, ScheduleNew.FieldID , ScheduleNew.Note, ScheduleNew.MonthsID , CoursesNew.CourseLogo , CoursesNew.EnglishName , (City.CityName +', ' +Country.CountryName) AS CityCountry FROM ScheduleNew ,CoursesNew , Country , City , Months Where Country.CountryID=City.CountryID AND City.CityID=ScheduleNew.CityID AND CoursesNew.CourseID=ScheduleNew.CourseID AND Months.MonthsID = ScheduleNew.MonthsID "
Dim dt As New DataTable
Dim da As New SqlDataAdapter(SQL, Conn)
If CountryID <> 0 Then
da.SelectCommand.CommandText = " AND City.CountryID = @CountryID"
da.SelectCommand.Parameters.Add("@CountryID", SqlDbType.Int).Value = CountryID
End If
If ScheduleID <> 0 Then
da.SelectCommand.CommandText &= "And ScheduleNew.ScheduleID =@ScheduleID"
da.SelectCommand.Parameters.Add("@ScheduleID", SqlDbType.Int).Value = ScheduleID
End If
If CourseID <> 0 Then
da.SelectCommand.CommandText &= "And ScheduleNew.CourseID =@CourseID"
da.SelectCommand.Parameters.Add("@CourseID", SqlDbType.Int).Value = CourseID
End If
If CityID <> 0 Then
da.SelectCommand.CommandText &= " And ScheduleNew.CityID =@CityID"
da.SelectCommand.Parameters.Add("@CityID", SqlDbType.Int).Value = CityID
End If
If StartCourse <> "" Then
da.SelectCommand.CommandText &= " And ScheduleNew.StartCourse Like @StartCourse "
da.SelectCommand.Parameters.Add("@StartCourse", SqlDbType.DateTime).Value = "%" & StartCourse & "%"
End If
If EndCourse <> "" Then
da.SelectCommand.CommandText &= " And ScheduleNew.EndCourse Like @EndCourse"
da.SelectCommand.Parameters.Add("@EndCourse", SqlDbType.DateTime).Value = "%" & EndCourse & "%"
End If
If MonthsID <> 0 Then
da.SelectCommand.CommandText &= " And ScheduleNew.MonthsID=@MonthsID"
da.SelectCommand.Parameters.Add("@MonthsID", SqlDbType.Int).Value = MonthsID
End If
If CategoryID <> 0 Then
da.SelectCommand.CommandText &= " And ScheduleNew.CategoryID=@CategoryID"
da.SelectCommand.Parameters.Add("@CategoryID", SqlDbType.Int).Value = CategoryID
End If
If FieldID <> 0 Then
da.SelectCommand.CommandText &= " And ScheduleNew.FieldID=@FieldID"
da.SelectCommand.Parameters.Add("@FieldID", SqlDbType.Int).Value = FieldID
End If
If Days <> 0 Then
da.SelectCommand.CommandText &= " And ScheduleNew.Days=@Days"
da.SelectCommand.Parameters.Add("@Days", SqlDbType.int).Value = Days
End If
da.SelectCommand.CommandText &= " order by StartCourse asc"
Try
da.Fill(dt)
Catch ex As Exception
'Error
Finally
Conn.Close()
End Try
Return dt
End Function
Image Of Page Register Here :
Thanks Alot ,
Noor Ali