0

I’m new to JavaScript. Basically I want a function in JavaScript which will show me an email preview in a web browser. I’ve stored email’s template, body and contents.

SQL:

SELECT Name, template, body, contents FROM Email
WHERE EmailID = 1

C#: I have a LinkButton (ID="lnkViewDoc") on asp.net page and the code behind is:

lnkViewDoc.Attributes.Add("onclick", "return preview_email();");

JavaScript: I need a function please which will pick values from the class fields and show it in a web browser. thanks

function preview_email() {

  ..................
  window.open() //Something
}

Contents:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org   
/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">     
<head>      
    <title></title>  
</head>  
<body>
  <center>
      ..................
  </center>
</body>

Body:

<div style="text-align: left">   Dear .......,
    ...........................................
</div>  
<div style="text-align: left">   &nbsp;</div>  
1

3 Answers 3

1

Take a look at the front-end server tags (bee stings). The ones I thing you're looking for are

<%=... %>

This is basically equivalent to Response.Write().

Sign up to request clarification or add additional context in comments.

Comments

0

Suppose you have a .NET object named "email". In code behind write:

lnkViewDoc.Attributes.Add("onclick", "return preview_email(" + email.EmailID + ");");

In javascript:

function preview_email(emailid) {

  ..................
  window.open("previewEmail.aspx?emailid=" + emailid, ... more parameters)
}

Comments

0

If you're not afraid of using jquery in your javascript newbie days, you can try to use Jquery Dialog like this:

$("<div></div>").load("previewEmail.ascx?emailid=5").dialog({autoOpen:true});

or something similar, you may want to consider just opening that same dialog with a iframe linking to the aspx, because your email will contain disturbing html elements like body tags

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.