Monday, March 26, 2012

pass through value of DropDownList ListItem into a string

Greetings.

I'm building an email form that uses a DropDownList to select the e-mail address via alias. Here is a portion of the control:

<asp:DropDownList id="ddlRecipient" CssClass="text-blue" AutoPostBack="true" runat="server">
<asp:ListItem Value="none" Selected="true">Please select from this list.</asp:ListItem>
<asp:ListItem Value="mornings">the morning show</asp:ListItem>
<asp:ListItem Value="news">News - newscasts, stories, comments</asp:ListItem>
</asp:DropDownList
Here is the code I am supposedly using to pass through the value:

Sub SendMe ()
Dim ddlRecipient As String
Dim ddlRecipientEmail As String = ddlRecipient & "@dotnet.itags.org.mydomain.com"
Response.Write(ddlRecipientEmail & " -- this is the email address you just sent")
End Sub

(The Response.Write line will be replaced by my email generation code, and I will use ddlRecipientEmail as the "from" field.)

However, all I get from the Response.Write is:
@dotnet.itags.org.mydomain.com -- this is the email address you just sent

So it's not passing through the value. How do I get it to do that?

Also, I'm going to do an If/Then/Else statement that, if "none" is the value, you get a popup and the program stops running. Anyone got a quick way to do that?

Appreciate the help.

ddlRecipient.SELECTEDVALUE


Curt_C:

ddlRecipient.SELECTEDVALUE

I actually just found that and it is working now.Thank you.

0 comments:

Post a Comment