ASP.NET Radio Button problem
Date: 02/07/05
(Web Development) Keywords: html, web
I am trying to read some radiobutton values into a a email function but
can't seem to get them to display if anyone has some ideas then let me
know, its doing my nut in.
Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
' radio button list one
dim NoOfStaff=New SortedList
NoOfStaff.Add("1","1-9")
NoOfStaff.Add("2","10-49")
NoOfStaff.Add("3","50-99")
NoOfStaff.Add("4","100-149")
NoOfStaff.Add("5","150-199")
NoOfStaff.Add("6","200-249")
tb9.DataSource=NoOfStaff
tb9.DataValueField="Key"
tb9.DataTextField="Value"
tb9.DataBind()
' Radio Button List One
dim TypeOfCompany=New SortedList
TypeOfCompany.Add("1","Engineering")
TypeOfCompany.Add("2","Clothing/Textiles")
TypeOfCompany.Add("3","Food/Drink")
TypeOfCompany.Add("4","Healthcare")
TypeOfCompany.Add("5","Creative Industry")
TypeOfCompany.Add("6","Other (Please specify below) * ")
tb10.DataSource=TypeOfCompany
tb10.DataValueField="Key"
tb10.DataTextField="Value"
tb10.DataBind()
' list of variables
Dim name, company, position, address, phone, fax, email, web, staff, type, other, comments, newsletter As String
request variables
name=request.querystring("tb1")
company=request.form("tb2")
position=request.form("tb3")
address=request.form("tb4")
phone=request.form("tb5")
fax=request.form("tb6")
email=request.form("tb7")
web=request.form("tb8")
staff=request.form("tb9")
type=request.form("tb10")
other=request.form("tb11")
comments=request.form("tb12")
newsletter=request.form("tb13")
End Sub
' Send Email Function
Sub send_email(Sender as Object, E as EventArgs)
If Page.IsValid Then
Dim comptype as String
If request.form("tb10")= 1 Then
comptype = "Engineering"
Elseif request.form("tb10")= 2 Then
comptype = "Clothing/Textiles"
Elseif request.form("tb10")= 3 Then
comptype = "Food/Drink"
Elseif request.form("tb10")= 4 Then
comptype = "Healthcare"
Elseif request.form("tb10")= 5 Then
comptype = "Creative Industry"
Elseif request.form("tb10")= 6 Then
comptype = "Other (Please specify below) * "
End If
Display1.text = comptype
Dim MsgBody as String
MsgBody = "Name: "
MsgBody = MsgBody + tb1.text
MsgBody = MsgBody + "
Company:"
MsgBody = MsgBody + tb2.text
MsgBody = MsgBody + "
Position in company: "
MsgBody = MsgBody + tb3.text
MsgBody = MsgBody + "
Address: "
MsgBody = MsgBody + tb4.text
MsgBody = MsgBody + "
Phone: "
MsgBody = MsgBody + tb5.text
MsgBody = MsgBody + "
Fax: "
MsgBody = MsgBody + tb6.text
MsgBody = MsgBody + "
Email: "
MsgBody = MsgBody + tb7.text
MsgBody = MsgBody + "
Web Address: "
MsgBody = MsgBody + tb8.text
'MsgBody = MsgBody + "
No of Staff: "
'MsgBody = MsgBody + tb9.text
MsgBody = MsgBody + "
Type: "
MsgBody = MsgBody + comptype
MsgBody = MsgBody + "
Other: "
MsgBody = MsgBody + tb11.text
MsgBody = MsgBody + "
Comments: "
MsgBody = MsgBody + tb12.text
MsgBody = MsgBody + ""
' Create new email and send it
Dim newMail As New MailMessage
newMail.BodyFormat = MailFormat.html
newMail.From = "info@accordia.org.uk"
newMail.To = tb7.text
newMail.Subject = "Ready2Change Feedback Form"
newMail.Body = MsgBody
' Sending mail
SmtpMail.SmtpServer = "192.168.1.2"
Smtpmail.Send(newMail)
End If
End Sub
Source: http://www.livejournal.com/community/webdev/169845.html