473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

RegisterStartupScript / Escape Character

I have a datagrid with a select button in it. When the button is clicked, I
want to kick off a mailto: to email the datagrid row. The user would specify
the recipients, and hit Send himself.

Here's my code

string sBody = string.Concat(
"Entered by: ", dgNotes.SelectedItem.Cells[2].Text, @"\",
Environment.NewLine,
"(", dgNotes.SelectedItem.Cells[4].Text, ")", @"\", Environment.NewLine,
dgNotes.SelectedItem.Cells[5].Text, @"\", Environment.NewLine);

string sSubject = "Emailing Project Notes";
string sScript = string.Concat(@"window.open('mailto:?subject=",
sSubject, "&body=", sBody, "')");

StringBuilder sbEMNote = new StringBuilder();
sbEMNote.Append(@"<script language=javascript>");
sbEMNote.Append(sScript);
sbEMNote.Append(@"</script>");

if (!Page.IsStartupScriptRegistered("EmailIndividualN ote"))
Page.RegisterStartupScript("EmailIndividualNote", sbEMNote.ToString());
An example of sScript was:
window.open('mailto:?subject=FMT - Emailing Project Notes&body=Entered by:
Durzi, George\\\r\n(7/2/2004 8:57:38 AM)\\\r\nTEST\\\r\n')

Works fine, except the carriage returns in the body were never displayed
properly. The body text that shows up in the message body is:
Entered by: Durzi, George(7/2/2004 8:57:38 AM)TEST

I had to escape the Environment.Newline otherwise I would get an
"unterminated string constant" javascript error.

Any idea how I can get the carriage return to show up properly in my message
body?
Nov 18 '05 #1
0 1493

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jon Maz | last post by:
Hi, I have been getting hopelessly confused with escaping escape characters in JScript! All I want to do is write a simple funtion: function DoubleUpBackSlash(inputString) { ??????? }
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
2
by: Dav | last post by:
In my ASP.NET codebehind I have the following code to jump to a certain section of the page: --- Dim strAnchorScript As String = "<script language='javascript'>" & _ "window.location.hash='#" &...
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.