| |

VerySource

 Forgot password?
 Register
Search
View: 1650|Reply: 13

Collect JS dynamically generated textbox

[Copy link]

1

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-9 13:40:01
| Show all posts |Read mode
I use JS to generate <input type = "text" /> on the client
Each has the same name = "autotext"
How to collect their values ​​in ASP NET (C #)
Reply

Use magic Report

1

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-14 10:27:01
| Show all posts
Everyone, help
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-14 12:54:01
| Show all posts
To access client-generated controls on the server, this is difficult
Can consider dynamically generating controls on the server side
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-14 13:00:01
| Show all posts
When submitted it will be an array.
Reply

Use magic Report

0

Threads

13

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-14 15:54:01
| Show all posts
If it is not a server control, the control generated by the client cannot be obtained by the server. Can consider using Ajax technology.
Reply

Use magic Report

0

Threads

29

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-1-14 17:09:01
| Show all posts
I also tried custom javascript changed the value of the server control, but the view State did not change, the value of the server control would still not change
Ajax can solve this problem. Without books in this area, I have no mood to read in English for the time being, hehe
Reply

Use magic Report

1

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-15 20:54:01
| Show all posts
Like <input type = "file" name = "files" />
Can be collected with system.web.httpfilecollection files = system.web.httpcontext.current.request.files;
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 United States

Post time: 2020-1-16 11:27:01
| Show all posts
You don't need to collect TEXTBOX, just collect their values. The values ​​submitted by multiple controls with the same name are separated by commas. Just use:
Reply

Use magic Report

1

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-17 08:27:01
| Show all posts
What is Split (',')
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-17 09:54:01
| Show all posts
For example, you submitted: 3 autotext = 1 autotext = 2 autotext = 3
Then the value obtained using Request.Form ["autotext"] is: 1, 2, 3
Request.Form ["autotext"]. Split (',') is to separate the above string with a comma to generate an array
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