textbox validation please help
-
HI, I have some text in a textbox that is reading directly from a database. My application is supposed to allow user to update this text, so it directly affects in the database content. Now in my text there are some special characters like : , ' href < >. The code works fine as long as the text data in the text box does not contain these characters. As soon as it encounters data with these characters it does not update the database, any suggestions to tackle this. I already tried, in web.config with no success
Raj D
-
HI, I have some text in a textbox that is reading directly from a database. My application is supposed to allow user to update this text, so it directly affects in the database content. Now in my text there are some special characters like : , ' href < >. The code works fine as long as the text data in the text box does not contain these characters. As soon as it encounters data with these characters it does not update the database, any suggestions to tackle this. I already tried, in web.config with no success
Raj D
-
dasumohan wrote:
As soon as it encounters data with these characters it does not update the database
It would be helpful if you described exactly what is happening, not just what is not happening.
--- single minded; short sighted; long gone;
Thanks for the response I have text box reading text content from database. When I change the text in the textbox and do update, it does not update in the database. I traced the problem to special characters like : and ' in the text field. When the text in the text field does not contain these special characters, it works fine. How to get around these special characters?
Raj D
-
Thanks for the response I have text box reading text content from database. When I change the text in the textbox and do update, it does not update in the database. I traced the problem to special characters like : and ' in the text field. When the text in the text field does not contain these special characters, it works fine. How to get around these special characters?
Raj D
You don't have to get around any characters, you just have to treat them properly. What do you do to update the database? What method are you using? Do you create an SQL query yourself? Do you use a parameterised query or do you concatenate the values into the query? I see no reason why a colon would be any problematic, but an apostrophe is a common problem if you concatenate strings into the query and don't encode the data properly first.
--- single minded; short sighted; long gone;