2012-07-24 45 views
0

我一直试图在Java中使用同样使用“\ n”去下一行,但它似乎并没有在此脚本工作。ASP C#基本的mailto功能

'\ n'不起作用,但整个功能没有它。

我的问题是你如何去下一行?

String text_name = Text_Name.Text; 
    String text_email = Text_Email.Text; 
    String text_message = Text_Message.Text; 

    ClientScript.RegisterStartupScript(this.GetType(), "mailto", 

     "<script type = 'text/javascript'>parent.location='mailto:" + "[email protected]" + 

     "?subject=" + "Inquiry" + 

     "&body=" + 

     "Contact Name: " + text_name + '\n' + 

     "Contact By: " + text_email + '\n' + 

     "Inquiry: " + text_message + '\n' + 

     "'</script>"); 

回答

2

尝试Environment.NewLine而不是'\n'

+0

编码这样 “Environment.NewLine”? – 2012-07-24 15:58:09

+0

就是这样! – 2012-07-24 15:59:01

0

使用Environment.NewLine,而不是\ n

"Contact Name: " + text_name + Environment.NewLine + 
0

尝试使用 '\ r \ n' 而不是 '\ n'。 或者你也可以使用 'Environment.NewLine'

MessageBox.Show("Line 1" + Environment.NewLine + "Line 2"); 

MessageBox.Show("Line 1\r\nLine2", "BlahBlah", MessageBoxButtons.OK, MessageBoxIcon.Question);