Link to home
Start Free TrialLog in
Avatar of ipgbarry
ipgbarryFlag for Australia

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
ASKER CERTIFIED SOLUTION
Avatar of philipjonathan
philipjonathan
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ipgbarry

ASKER

Great thanks worked first time.
string js = textbox.Text.Replace("'", "''");