user control and postback
-
hi, I've got a user control which is loaded onto the webform via a dropdownlist. the user control has a button control on it which is supposed to update an sql database. but when the button is clicked the page returns to its original state, minus the usercontrol, this is because of the postback, plus the code in the button control does not seem to execute as the database is not updated. I know all the code works, only if the usercontrol is put directly on the page i.e. postback does not have any effect. anybody have any ideas on how to get around this??? Thanks JetSet
-
hi, I've got a user control which is loaded onto the webform via a dropdownlist. the user control has a button control on it which is supposed to update an sql database. but when the button is clicked the page returns to its original state, minus the usercontrol, this is because of the postback, plus the code in the button control does not seem to execute as the database is not updated. I know all the code works, only if the usercontrol is put directly on the page i.e. postback does not have any effect. anybody have any ideas on how to get around this??? Thanks JetSet
Be sure the user control is added before the Viewstate is loaded. One easy and slick way to do this is to directly add the user control to your page (using the designer) as if you were always going to show it. Then set the
Visible
property to false. So when the user changes the dropdown list setVisible
to true. Regards, Alvaro