I have TextBox in MultiLine mode. Text property contains some newlines (\r\n).
Why there is a difference between data returned to server on full postback — "\r\n" is returned and on async postback — "\n" is returned?
User agent: IE, Firefox, Edge, Chrome
aspx:
<asp:UpdatePanel runat="server" ID="up">
<ContentTemplate>
<asp:TextBox runat="server" ID="tbText" TextMode="MultiLine" Height="200px" />
<asp:Label runat="server" ID="lDump" /><br />
<asp:Button runat="server" ID="btnAsync" Text="Async postback" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button runat="server" ID="btnFull" Text="Full postback" />
aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
btnAsync.Click += Dump;
btnFull.Click += Dump;
if (!IsPostBack)
tbText.Text = "Line1\r\nLine2\r\nLine3";
}
private void Dump(object sender, EventArgs e)
{
lDump.Text = tbText.Text.Replace("\r", "[CR]").Replace("\n", "[LF]");
}
output:
- Async postback: Line1[LF]Line2[LF]Line3
- Full postback: Line1[CR][LF]Line2[CR][LF]Line3