Click here to Skip to main content
15,881,871 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how to get previous page and details remain Pin
Bernhard Hiller31-Jul-11 19:45
Bernhard Hiller31-Jul-11 19:45 
QuestionHow to replace image onmouseover Pin
Eddie198730-Jul-11 9:12
Eddie198730-Jul-11 9:12 
AnswerRe: How to replace image onmouseover Pin
Shahriar Iqbal Chowdhury/Galib31-Jul-11 4:16
professionalShahriar Iqbal Chowdhury/Galib31-Jul-11 4:16 
GeneralRe: How to replace image onmouseover Pin
Eddie19871-Aug-11 1:09
Eddie19871-Aug-11 1:09 
GeneralRe: How to replace image onmouseover Pin
Not Active1-Aug-11 2:08
mentorNot Active1-Aug-11 2:08 
QuestionHave Session in Global.asax File Pin
Member 322226430-Jul-11 6:29
Member 322226430-Jul-11 6:29 
AnswerRe: Have Session in Global.asax File Pin
Keith Barrow30-Jul-11 8:23
professionalKeith Barrow30-Jul-11 8:23 
Questionneed to display data on email Pin
CyberHeart 230-Jul-11 6:20
CyberHeart 230-Jul-11 6:20 
Hey!
I have been trying several times to fix it but couldnt find correct codes in C#. You can copy all these below codes of markup and C# so that you will see what is problem. Im fine with markup but only problem with C#. There is some explanations (bold and underline) below. Your help will be highly appreciated. Thanks so much for your time Smile | :) Looking forward to hearing from you!

Markup:

<form id="Form1" method="post" runat="server">
<label><asp:TextBox ID="txtName" runat="server"></asp:TextBox>Name:</label>
<label><asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>Email Address:</label>
Order the following cards:
<asp:ListBox name="order" Runat="server" ID="dlist1" SelectionMode="Multiple" onchange="swapImage1()">
<asp:ListItem>SOW SEEDS OF LOVE</asp:ListItem>
<asp:ListItem data-card="R 32.00" data-memo="R 62.00" Value="Images/Bday.jpg">Birthday</asp:ListItem>
<asp:ListItem data-card="32.00" data-memo="62.00" Value="Images/Wedding.jpg">Wedding</asp:ListItem>
</asp:ListBox>

Display prices when clicked an item on listbox control:
<script type="text/javascript">
window.onload = function()
{
document.getElementById("dlist1").onchange = function() {
var option = this.options[this.selectedIndex];
document.getElementById("price_card").innerHTML = option.getAttribute("data-card") ? option.getAttribute("data-card") : "";
document.getElementById("price_memo").innerHTML = option.getAttribute("data-memo") ? option.getAttribute("data-memo") : "";
}
}
</script>

Display image when clicked an item on this ListBox control (above):
<div>
<asp:Image ID="imageToSwap1" runat="server" width="147" height="195" ImageUrl="" />
</div>
<script type="text/javascript">
function swapImage1() {
var image = document.getElementById('<%= imageToSwap1.ClientID %>');
var dropd = document.getElementById('<%= dlist1.ClientID %>');
image.src = dropd.value;
};
</script>

1) After choosing an item (birthday card) on ListBox control, then you decide to choose "card A6" on input control using checkbox but you also choose another item (wedding card) on ListBox control, so you also choose "memo book" (only for wedding card)
2) Look below (bold) -- id="price_card" and id="price_memo" are implemented by Javascript to display several price

<table>
<tr>
<td input type="checkbox" name="description" value="Card A6" id="description1" runat="server" /> Card A6 (blank)</td>
<td id="price_card"></td>
</tr>
<tr>
<td input type="checkbox" name="description" value="Memo Book A6" id="description2" runat="server" /> Memo book </td>
<td id="price_memo"></td>
</tr>
</table>

For example: if you wanna order two cards (card A6 for birthday card and memo book for wedding card), then clicking on send button to send this data to my gmail account:

<asp:Button ID="Send" runat="server" Text="Send Email" onclick="Send_Click1" />
</from>
I have no problem with this markup but have a little problem with codes (C#). After you sent order data to my gmail account, I will get your email and can read this data what you wanna order.

This order data should be displayed on email: (thats what I want)

Name: xxx
Email Address: xxx
Order 1: Images/Birthday.jpg
Description 1: Card 6
Order 2: Images/Wedding.jpg
Description 2: Memo Book

My current problem:
Name: xxx
Email Address: xxx
Order 1: Images/Birthday.jpg (no display)
Description 1: Card 6 (display) - fine
Order 2: Images/Wedding.jpg (no display)
Description 2: Memo Book (no display)

Im struggling with codes in C# - look at below and you can test these codes (copy) to receive your email on your gmail account after clicking on send button. You will see some order data is missing:

protected void Send_Click1(object sender, EventArgs e)
{
string msg = "---------------------------<br>";
string from = "youremail@gmail.com";
string to = "youremail@gmail.com";
MailMessage mail = new MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "Ellie Rose", System.Text.Encoding.UTF8);
mail.Subject = "Customer Order from Ellie Rose Website";
mail.SubjectEncoding = System.Text.Encoding.UTF8;

msg += "Name: " + txtName.Text;
msg += "<br>Email: " + txtEmail.Text;

if (description1.Checked == true) //Card A6 - need to display data on email - not working
{
msg += "<br>Description 1:" + description1.Value;
msg += "<br>ORDER 1: " + Request["order"];
}
if (description2.Checked == true) //Memo Book - need to display data on email - not working
{
msg += "<br>Description 2:" + description2.Value;
msg += "<br>ORDER 2 : " + Request["order"];
}

mail.Body = msg;
mail.BodyEncoding = System.Text.Encoding.ASCII;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
//Add the Creddentials- use your own email id and password
client.Credentials = new System.Net.NetworkCredential(from, "yourpassword");
client.Port = 587; // Gmail works on this port
client.Host = "smtp.gmail.com";
client.EnableSsl = true; //Gmail works on Server Secured Layer
try
{
client.Send(mail);
}
catch (Exception ex)
{
Exception ex2 = ex;
string errorMessage = string.Empty;
while (ex2 != null)
{
errorMessage += ex2.ToString();
ex2 = ex2.InnerException;
}
HttpContext.Current.Response.Write(errorMessage);
} // end try
}
AnswerRe: need to display data on email Pin
Not Active30-Jul-11 13:01
mentorNot Active30-Jul-11 13:01 
QuestionRender ASP.Net code at run time Pin
Dilan200630-Jul-11 3:06
Dilan200630-Jul-11 3:06 
AnswerRe: Render ASP.Net code at run time Pin
Ali Al Omairi(Abu AlHassan)30-Jul-11 7:05
professionalAli Al Omairi(Abu AlHassan)30-Jul-11 7:05 
AnswerRe: Render ASP.Net code at run time Pin
Dilan200630-Jul-11 15:54
Dilan200630-Jul-11 15:54 
GeneralRe: Render ASP.Net code at run time Pin
Dilan200631-Jul-11 5:13
Dilan200631-Jul-11 5:13 
GeneralRe: Render ASP.Net code at run time Pin
Ali Al Omairi(Abu AlHassan)4-Aug-11 6:27
professionalAli Al Omairi(Abu AlHassan)4-Aug-11 6:27 
QuestionUnexpected function of validation controls and tab panel [modified] Pin
Dominick Marciano29-Jul-11 9:05
professionalDominick Marciano29-Jul-11 9:05 
Questiongoogle maps api Pin
loveleen9028-Jul-11 20:11
loveleen9028-Jul-11 20:11 
AnswerRe: google maps api Pin
Blue_Boy28-Jul-11 20:57
Blue_Boy28-Jul-11 20:57 
Questionexcel workbook problem Pin
Sneha Bisht28-Jul-11 19:14
Sneha Bisht28-Jul-11 19:14 
QuestionWeb application and web site to co-exist Pin
vanikanc28-Jul-11 4:14
vanikanc28-Jul-11 4:14 
AnswerRe: Web application and web site to co-exist Pin
Shameel28-Jul-11 4:23
professionalShameel28-Jul-11 4:23 
Questiontooltip Pin
apadana_198928-Jul-11 3:48
apadana_198928-Jul-11 3:48 
AnswerRe: tooltip Pin
Blue_Boy28-Jul-11 4:41
Blue_Boy28-Jul-11 4:41 
AnswerRe: tooltip Pin
Ali Al Omairi(Abu AlHassan)4-Aug-11 12:41
professionalAli Al Omairi(Abu AlHassan)4-Aug-11 12:41 
QuestionXSLT - for-each-group Pin
rajesh198828-Jul-11 0:25
rajesh198828-Jul-11 0:25 
AnswerRe: XSLT - for-each-group Pin
Not Active28-Jul-11 1:06
mentorNot Active28-Jul-11 1:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.