G
Guest
Hi all,
Longtime ASP developer getting feet wet with ASP.NET, has banged head on
this problem for many hours, go easy.
The Code Project has a nice article on making a "self configuring form
mailer web control." Basically, you apply this control to any form with
ASP.NET textbox server controls on it and it turns the form into something
that's automatically mailed out to an e-mail you specify. Read all about it
here:
http://www.codeproject.com/aspnet/SelfConfigFormMailer.asp
The code works great for textboxes. The author of the article leaves it as
"an exercise for the reader" to configure the program for other types of
controls. The relevant section of code reads as follows:
{
if (control is TextBox)
{
TextBox textBox = (TextBox)control;
if (textBox.Text.Length > 0)
{
if (textBox.ID.ToLower().EndsWith("subject"))
{
subject = textBox.Text; // subject is added as a mail header later
in the code
}
else if (textBox.ID.ToLower().EndsWith("emailaddress"))
{
replyTo = textBox.Text; // add a reply-to header, and
// append the to the text of the message
messageText.Append(mailTemplate.getTemplateText(textBox.ID,
textBox.Text));
}
else
{ // general case, just append to the email body
messageText.Append(mailTemplate.getTemplateText(textBox.ID,
textBox.Text));
}
}
}
// >>> add more types of controls within else if clauses here <<<
}
So what you have going on is the script generates an e-mail string at
runtime using the IDs and Text that are specified by the form developer.
I want the script to work with DropDownLists. I can't figure out how to make
it access the values of the selected listitems. Most of the dropdown scripts
I've seen around the net presume that the name of the parent control
(DropDownList) is specified prior to runtime, but wiring this information in
defeats the point of this generic script.
I've tried a +lot+ of variations, e.g.:
messageText.Append(mailTemplate.getTemplateText(DropDownList.ID.Selecteditem
..Value, DropDownList.ID.Selecteditem.Text))
No joy so far. Can someone help out with what's probably an easy question?
Thanks,
Ken Fine
(e-mail address removed)
http://www.ideapod.org
Longtime ASP developer getting feet wet with ASP.NET, has banged head on
this problem for many hours, go easy.
The Code Project has a nice article on making a "self configuring form
mailer web control." Basically, you apply this control to any form with
ASP.NET textbox server controls on it and it turns the form into something
that's automatically mailed out to an e-mail you specify. Read all about it
here:
http://www.codeproject.com/aspnet/SelfConfigFormMailer.asp
The code works great for textboxes. The author of the article leaves it as
"an exercise for the reader" to configure the program for other types of
controls. The relevant section of code reads as follows:
{
if (control is TextBox)
{
TextBox textBox = (TextBox)control;
if (textBox.Text.Length > 0)
{
if (textBox.ID.ToLower().EndsWith("subject"))
{
subject = textBox.Text; // subject is added as a mail header later
in the code
}
else if (textBox.ID.ToLower().EndsWith("emailaddress"))
{
replyTo = textBox.Text; // add a reply-to header, and
// append the to the text of the message
messageText.Append(mailTemplate.getTemplateText(textBox.ID,
textBox.Text));
}
else
{ // general case, just append to the email body
messageText.Append(mailTemplate.getTemplateText(textBox.ID,
textBox.Text));
}
}
}
// >>> add more types of controls within else if clauses here <<<
}
So what you have going on is the script generates an e-mail string at
runtime using the IDs and Text that are specified by the form developer.
I want the script to work with DropDownLists. I can't figure out how to make
it access the values of the selected listitems. Most of the dropdown scripts
I've seen around the net presume that the name of the parent control
(DropDownList) is specified prior to runtime, but wiring this information in
defeats the point of this generic script.
I've tried a +lot+ of variations, e.g.:
messageText.Append(mailTemplate.getTemplateText(DropDownList.ID.Selecteditem
..Value, DropDownList.ID.Selecteditem.Text))
No joy so far. Can someone help out with what's probably an easy question?
Thanks,
Ken Fine
(e-mail address removed)
http://www.ideapod.org