Reputation: 21023
I have a web forms app which has a piece of jquery that generates a set of inputs, sets the names and ID's correctly to the web forms type names and ID's.
Yet when i post the form back to the server, i cannot find any of those controls with FindControl
, though i am able find the original control that is part of the form that the other inputs are clone
d from.
I have attempted to use FindControl
and used a Recursive version of FindControl
that i have created, but nothing can be found. Do i have to go down the Request.Form
route, or am i missing something?
Upvotes: 0
Views: 475
Reputation: 902
The reason you can't find the control is because you generate them on the client side and not from the server side. using runat=server
you can:
call ajax method to send the data from the imputs to the server
Create the dynamic inputs from your server side, using repeater of listview
Upvotes: 0
Reputation: 148150
You wont find the controls
generated by jQuery
on server side as server controls have their ViewState
which asp.net uses on post back. You can use a hidden field to assign the values of your dnymically generaterd code to it and get them from this hidden field on server side code. You will need to make hidden field runat="server"
<input type="hidden" id="hdnjQueryGeneratedControls" runat="server" />
OR
<asp:HiddenField id="hdnjQueryGeneratedControls" runat="server" />
Upvotes: 1