Skip to content
Advertisement

Asp.net multiple replace characters in insert statement?

I have a SQL insert statement in my asp.net webpage and I have to replace a testbox contents if a “:” exists with nothing”” like the following

TextBox.Text.Replace(":", "")

Is there a way that I can add an additional character to replace? I need to also remove a “#” if entered into a textbox.

Advertisement

Answer

I don’t know if any of these will work, but it’s worth a try:

TextBox.Text.Replace(":", "").Replace("#", "")

Or

String mytext = TextBox.Text;
mytext.Replace(":", "");
mytext.Replace("#", "");
TextBox.Text = mytext;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement