0
Answer

Add usercontrol to placeholder dynamically in content page

user

user

10y
1k
1

I have a content page with two hyperlinks A and B and a placeholder. If hyperlink A is clicked add A.ascx and if hyperlink B is clicked add B.ascx to the placeholder. Both A.ascx and B.ascx have a textbox and an Add button to add data to SQL tables. (A.ascx updates TableA and B.ascx updates TableB)

I am facing below problem

When content page loads and the page have only two hyperlinks A and B. I click on hyperlink A then A.ascx gets added to placeholder. I enter value in textbox and click on Add button. The database is successfully updated.

Next I click on hyperlink B then B.ascx gets added to placeholder. I enter value in textbox and click on Add button. The Add event is not getting called and the value in textbox is getting cleared. If I re-enter the same value in textbox and click on Add button again then the data is getting saved.

Can you please help me in fixing the problem?

Thanks.

Next Recommended Forum