views:

159

answers:

3

Hi, I have next situation:

  • I load dynamic controls during on init, and I do correct initialization.
  • I add dynamic control before postback
  • I don't add anything later in load
  • control is loaded and diplayed correctly
  • I press postback and nothing happens

Why I really don't know.. I tried everything. So control IS properly initialised. __EVENTTARGET shows the same path as the UniqueId of linkbutton that is firing it. All controls in tree have viewstate=true. So, I really don't know what this is not working.

Any idea? I am desperate.. I don't know.. if anyone could suggest me, if not solution, then just things I should check would be very good.

A: 

Is this problem just for this page or do you have other pages on the same site with the same problem?

I am assuming that you have the same problem on all pages.

It could be relate do javascript not being allowed. You could try to add the site to local intranet security are, then refresh the page.

Shiraz Bhaiji
No i have javascript. postback does happen. Form is submited.
Vjeran
Just to make sure: You see that the form is submitted when you press the button? (for example an entry in the IIS log)
Shiraz Bhaiji
A: 

Dynamic controls have to be added back to the control tree on each postback for the events to fire.

rick schott
A: 

Dynamically created controls are not part of their container's viewstate, so setting it to TRUE wouldn't have any effect on the situation and are not evaluated until after the on_init call completes anyways.

I would wrap the logic that is populating these dynamic controls in with a conditional check for a postback if(!IsPostBack) { //Insert logic here }

If your dynamic controls take input from the user, or need access to their view state, then you would need to move this call to the Page_Load method as this is the point in the page's lifecycle where viewstate is first evaluated.

jlech