ipgbarry
asked on
C# how to insert this javascript into SQL onFocus="alert('Error');"
HI am writing a C# app
I want to add some javascript into my SQL server.
Eg
onFocus="alert('Error');"
it errors on the single quotes. If I type 2 single quotes in my texBox;
Eg
onFocus="alert(''Error''); "
it works fine. I am trying to handle this in my code save doing it in the textbox.
I have paramatised the string in the data class I have made which I thought would sort it out it that didn't.
I guessing I need to use .Replace but have not managed to get the syntax right.
Any help would be appreciated.
Cheers
Baz
I want to add some javascript into my SQL server.
Eg
onFocus="alert('Error');"
it errors on the single quotes. If I type 2 single quotes in my texBox;
Eg
onFocus="alert(''Error'');
it works fine. I am trying to handle this in my code save doing it in the textbox.
I have paramatised the string in the data class I have made which I thought would sort it out it that didn't.
I guessing I need to use .Replace but have not managed to get the syntax right.
Any help would be appreciated.
Cheers
Baz
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
string js = textbox.Text.Replace("'", "''");