i fill texboxes with:
foreach (user u in userinfo) { txtnickname.text = u.nickname; txtfirstname.text = u.firstname; txtlastname.text = u.lastname; txtemail.text = u.email; } my textboxes filled data database.
for example fill new values in of texboxes , click on button, happens this:
if (txtnickname.text != string.empty && txtfirstname.text != string.empty && txtlastname.text != string.empty && txtemail.text != string.empty) { //todo } but when debug: values of textboxes old values (the values foreach-loop), , not new values fill in textboxes.
why happening? i'm loading data database in textboxes, after i'm changing values of textboxes myself, , when debug textbox values still database-values (see foreach-loop).
if first loop executed in page_load event should sure don't execute again when page posted result of clicking on button.
more info in page.ispostback on msdn
private void page_load() { if (!ispostback) { // code should executed when page being // rendered first time not when responding postback // raised <runat="server"> controls userinfocollection userinfo = getuserinfocollection(); foreach (user u in userinfo) { txtnickname.text = u.nickname; txtfirstname.text = u.firstname; txtlastname.text = u.lastname; txtemail.text = u.email; } } }
Comments
Post a Comment