Solved

postback not workign on usercontrol

Posted on 2010-08-13
4
269 Views
Last Modified: 2013-11-07
so i have a user control that i load dynamically at run time into an asp:panel.
i use AJAX popup extender to make this panel a modal window showing the dynamically loaded user control.

the problem is the control fires events the first time and then when buttons on the UC are clicked like SAVE, DELETE, CANCEL there is no post back and the button click events dont execute.

how can I get the button events to work as expected on post backs?
0
Comment
Question by:realcoding
4 Comments
 
LVL 13

Expert Comment

by:iHadi
ID: 33433504
Well, it's hard to say without seeing any code, but I suggest that you dynamically load you UC on page_init if you are not doing so (especially on postback)
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33434859
Hi,

(1) Have you bind these all controls of your UC with some event handler?

(2) Is the AutoPostBack property of Controls is set to True.

Regards,
VSS
0
 
LVL 5

Accepted Solution

by:
KiasChaos83 earned 500 total points
ID: 33436123
Hi there,

ASP.NET has a big gotcha with dynamically created controls. Did you know that with dynamically created controls, you need to re-create and re-add the controls to the page on EVERY page load? Not only that, you will find that with dynamically created controls their ViewState and their event will go missing or will not fire IF they aren't recreated on the page_init event.

If you are using dynamically created controls then you'll be wise to make sure you recreate them on every page_init.
0
 

Author Comment

by:realcoding
ID: 33445547
guys that seems to be all well and fine but even after i remake my UC on the init() event i dont get button clicks firing...

how will the UC know when to fire events?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax error 9 45
C# Offline Apllication 5 48
Error in query expression 3 30
Facial recognition to look through the whole database for a person 3 39
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

947 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now