.net - accessing user generated control via findControl method -
i have jquery function lets users add textboxes inside "div" id of "textboxcontainer".
so html this:
<div id="textboxcontainer"> <table> <tr> <td><input type="text" name="fname" value="john"></td> </tr> <tr> <td><input type="text" name="lname" value="smith"></td> </tr> <tr> <td><input type="text" name="city" value="new york city"></td> </tr> </table> </div>
i'm trying access these textboxes via find control this, not working. it's returning null reference error.
does know why it's failing? thanks
dim textboxcontainer htmlgenericcontrol = ctype(page.findcontrol("textboxcontainer"), htmlgenericcontrol) each control htmlinputtext in textboxcontainer.controls.cast(of htmlinputtext)() if typeof control htmlinputtext 'do response.write(control.value) end if next
obviously inputs generated on clientside not visible on serverside, because not regenerated during postback lifecycle, not way that.
if need dynamic input generation , want read values on serverside ajax solution. should create inputs during ajax callbacks on serverside , able read values during following round trips, approach performance may slower.
edit: mean here if create inputs on clientside jquery on serverside have problems reading values. suggestion was... create inputs jquery on button click. instead of on button click can make ajax call server (by placing inputs container , button inside update panel) , during ajax callback can create inputs on serverside accessing textboxcontainer should marked runat=server , adding children via textboxcontainer.controls.add(children). after modified html returned client , during next postback when post data able find controls findcontrol method.
another idea figured out: maybe possible hidden field , serialize values value of input field, can deserialize values on serverside , hence bypass findcontrol method (you need access hidden field).
Comments
Post a Comment