| |

VerySource

 Forgot password?
 Register
Search
View: 1812|Reply: 5

An awkward script problem

[Copy link]

7

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 Invalid IP Address

Post time: 2021-3-9 15:30:02
| Show all posts |Read mode
I wrote the following code in the 1.aspx screen button click event in ASP.NET:
Dim scriptStr As String = "<script>" + vbCrLf
scriptStr += "document.all.tbxitemJap.value = document.all.tbxitemJap.value +'" + DB + "';"
scriptStr += "</script>"

Among them, DB is a variable, which is obtained from the database.
But there may be such data in my database Lao People's
For this kind of data with ', this script will report an error, what should be done?
Is it necessary to convert this variable into ASCII code, and then turn it back?
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2021-3-9 15:45:01
| Show all posts
Just turn it around.
Reply

Use magic Report

0

Threads

64

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2021-3-9 16:00:02
| Show all posts
DB = DB.replace("'","\'").replace(Chr(13),"").replace(chr(10),"\n")
Reply

Use magic Report

7

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 Invalid IP Address

 Author| Post time: 2021-3-9 16:30:01
| Show all posts
In DB, 'does not necessarily appear at position 13
How to turn back after turning like this
DB also shows on the screen
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2021-3-9 16:45:01
| Show all posts
See the following example for escaping in js:

var str="Lao People\'s ";
document.write(str);
Reply

Use magic Report

7

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2021-3-9 17:15:02
| Show all posts
OK thanks
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list