| |

VerySource

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

Attributes do not respond in Button event

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-20 14:20:01
| Show all posts |Read mode
I wrote the following code in the Button_onclick event:
Button btnDel = (Button) sender;
Response.Write ("<script language = javaScript> alert ('hhh'); </ script>");
// This sentence can pop up a dialog box
btnDel.Attributes ["onclick"] = "alret ('AAA')";
// but this sentence does not work

Later, I wrote <script language = javaScript> alret ("AAA_2") </ sript> on the client
Result: The "AAA_2" dialog box pops up first, and the dialog box in the click event can pop up.
What is the problem ???
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-29 15:45:01
| Show all posts
btnDel.Attributes ["onclick"] = "alret ('AAA')";
 Be sure to put this sentence on PAGELIAD! Ispostback
  Inside, there must be JS code in the front desk

Can be written directly in! ISPOSTBACK of PAGELOAD

btnDel.Attributes ["onclick"] = "<script language = javaScript> alert ('hhh'); </ script>";
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-29 17:27:02
| Show all posts
btnDel.Attributes ["onclick"] = "alret ('AAA')";
// but this sentence does not work

Because you wrote it wrong, alret was changed to alert
Reply

Use magic Report

0

Threads

11

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-29 18:00:01
| Show all posts
Apply ATTRIBUITE's ADD method! !! !! Of course, you can't pass values ​​directly.
Reply

Use magic Report

0

Threads

10

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-9 15:45:01
| Show all posts
btnDel.Attributes.Add ("onclick", "alert ('AAA')")
Put this in the page_load event! !!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Hong Kong

Post time: 2020-8-23 12:00:01
| Show all posts
Response.Write("<script language='JavaScript'>alert('Please enter the category name!');window.location='setmenu.aspx';</script>")
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