asp.net - How to get value of control programmaticaly created, before postback erase them ? -
i'm creating dynamic controls via code
' fields array of string each field string in fields if field.trim <> "" fieldqty += 1 dim mylab new label mylab.text = field mylab.id = "lblinfo" & fieldqty dim mytxt new textbox mytxt.id = "txtinfo" & fieldqty paninfo.controls.add(mylab) paninfo.controls.add(mytxt) end if next session("fieldsqty") = fieldqty
then, i've button want save or send via email content of fields.
protected sub btnsave_click(sender object, e eventargs) handles btnsave.click k integer = 1 cint(session("fieldsqty")) dim mytxt textbox dim mylbl label lblmsg.text = paninfo.controls.count 'here got 0 mylbl = ctype(paninfo.findcontrol("lblinfo" & k), label) 'here mylbl = nothing mytxt = ctype(paninfo.findcontrol("txtinfo" & k), textbox) 'here mytxt = nothing next k end sub
it seems after click button controls disappear (not value: both value , controls).
i know these controls dinamically created, not re-create after postback, after click button disappear , can't neither save value in it. why ?
thanks
edit: ok i've question: how value of control on button click?
Comments
Post a Comment