webcontrols automatic replacing characters

S

sacred

Hi,

I have a simple question I beleive. How do i turn off the
feature that goes through and replaces sensitive
characters to HTML with its corresponding character tag.

For instance I am using a textbox where people can use a
single qoute. As in <Nacy's house>. So,before I submit it
to the database I go through do a replace "'" with &qoute;
(otherwise it breaks the sql server update/insert).

However, when pulling back up the record Microsoft's web
control to the screen. The web control goes through and
replaces the "&" in &qoute; with "&amp;qoute" which
totally messes up the HTML.

How can I turn off this feature?

Many Thanks,

Sacred
 
S

sacred

You can't turn it off from all my research I couldn't find
a solution. I even added a control object of a ltieral
and it still parsed through and replace the & wwith &amp;

So the solution I used was to use a HTML web control
textarea. When I do that and use InnerHTML property it
doesn't parse through and replace it.

Many thanks,

sacred
 
K

Kevin Williams

For instance I am using a textbox where people can use a
single qoute. As in <Nacy's house>. So,before I submit it
to the database I go through do a replace "'" with &qoute;
(otherwise it breaks the sql server update/insert).

You shouldn't need to do this if you're using a parameterized query
(it will escape single quotes and stuff automatically). ie:

SqlConnection connection = new SqlConnection( connectstring );
SqlCommand command = new SqlCommand( "UPDATE table SET col = @value
WHERE something = whatever", connection );
command.Parameters.Add( "@value", textbox.Text );
However, when pulling back up the record Microsoft's web
control to the screen. The web control goes through and
replaces the "&" in &qoute; with "&amp;qoute" which
totally messes up the HTML.

I'm not sure how this is happening - I've never seen it happen. I
just set the Text property on the textbox control to the value from
the database and it always displays properly... Can you post a small
code sample?

-Kevin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top