asp c#basic mailto函数

时间:2012-07-24 15:55:43

标签: c# javascript asp.net

我一直在尝试使用类似在Java中使用的'\ n'来下一行,但它似乎不适用于此脚本。

'\ 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:" + "someone@gmail.com" +

       "?subject=" + "Inquiry" +

       "&body=" + 

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

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

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

       "'</script>"); 

4 个答案:

答案 0 :(得分:2)

尝试使用Environment.NewLine代替'\n'

答案 1 :(得分:0)

使用 Environment.NewLine 代替 \ n

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

答案 2 :(得分: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);

答案 3 :(得分:0)

尝试将%0A放入mailto中的新行