简体   繁体   English

在Asp.net的FreeTextBox控件中获取NewLine字符

[英]Getting NewLine character in FreeTextBox control in Asp.net

I am using FreeTextBox control 我正在使用FreeTextBox控件

in asp.net.When I am getting its HtmlStrippedText in my code I am getting the String without HTML tags.Now how can I get the new line character from this String ie I want to Replace All the NewLine characters with Special Symbol "@". 在asp.net中。当我在代码中获取其HtmlStrippedText时,得到的字符串没有HTML标记。现在如何从该字符串中获取换行符,即我想用特殊符号“ @”替换所有的换行符。

Got the Solution: 得到了解决方案:

Got the HtmlStrippedText in String str and then got replace it like this: 在String str中获得HtmlStrippedText,然后像下面这样替换它:

char enter=(char)111;
temp= str.Replace(enter+"", "\n");

如果它类似于基本的ASP:TextBox,则只需从text属性中获取字符串,然后执行类似的操作

 var test = txtYourControl.Text.Replace(Environment.NewLine, "@");

This will vary between browsers (perhaps even between the operating systems on which the browser is running). 这在浏览器之间(甚至在运行浏览器的操作系统之间)也有所不同。 More on newline definitions here . 更多关于换行符的定义在这里

I have found the most reliable option to be to search and replace "\\n" rather than Environment.NewLine which is "\\r\\n" in a Windows environment. 我发现最可靠的选择是搜索和替换“ \\ n”,而不是Environment.NewLine,它在Windows环境中是“ \\ r \\ n”。

string text = this.txtField.Text.Replace("\n", "@");

HtmlStrippedText is used to get the plain text You should use the text property of freetextbox control HtmlStrippedText用于获取纯文本您应该使用freetextbox控件的text属性

u can remove new line using this code. 您可以使用此代码删除新行。

lblTitle.Text = txtFreetextbox.Text.Replace("<br>","@");

Click this link 点击此链接
http://freetextbox.com/docs/ftb3/html/P_FreeTextBoxControls_FreeTextBox_Text.htm http://freetextbox.com/docs/ftb3/html/P_FreeTextBoxControls_FreeTextBox_Text.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM