Wednesday, March 28, 2012

Update UserControl from another UserControl in an UpdatePanel

I've got 2 usercontrols on my webpage (let's call them uc1 and uc2). In uc1 is a button. When I click on the button I bubble up the event to the main page. In the main page I handle the event. In the event handler on the main page I set a property of uc2 which sets the text of a label in uc2. I want this interaction to happen in an UpdatePanel so that the screen doesn't postback, but I can't seem to get it to work. Any direction would be greatly appreciated. I have a sample app if someone wants to see it.

Hi

I use that technique in nblogr. You can download nblogr's source from codeplex.

Basically you expose a method in your uc2 something like void DoUpdate()
And in that method you call myUpdatePanelID.Update()

and that should do the trick

Hope this helps you a little


Thanks so much! That did the trick!

Could you be a bit more specific? I downloaded that code but there is a lot of code there. Looking for a snippet....

Thanks.

Jeff


What part are you having trouble with? Bubbling up the event from the first control and modifying the second one, or having the UpdatePanel refresh after the changes have occurred?

I was having a similar issue. I've got two controls in two separate panels on one page and I'm using the event bubbling to get the two controls to communicate and toggle their visibility. I was forced to click the first control's button twice before the intended result would take place, even though all the code would execute while debugging. It seemed the first click wasn't updating the client but the second one did. Then I took a closer look at my container page, I didn't have the two controls in an UpdatePanel, even though the container page was setup for ajax. Wrapping the all the controls and panels in an UpdatePanel got it sorted.

Just thought it would be useful to note here.

-jason


Hi, What i have done in my application is like i have a combo inside a usercontrol , another control includes

a login page type controls , Now when ever the user selects any thing from the combo control the text on the login control also changes without full page refresh. If this is your prob. then below is how i did it.

Put your combo control inside UpdatePanel and contentTemplate tag. Dont do any thing with login control just put both of them on aspx page inside a Scriptmanager tag. and on page load of Login control put your logic . If this is not sufficient then i can send you the code .

Can you tell me how to stop the mail of Posts from this site to my mail box, or how to unsubscribe. becoz this thing has filled my personal ID.

Shrikant

No comments:

Post a Comment