Sunday, March 11, 2012

How can I communicate two updatepanels?

hello.

that should happen automatically...


I think that you didn't understood...

I want to usercontrol, in, Update Panel 1 updates, when a Button in my usercontrol, that is in UpdatePanel2, is pressed.

Thanx!

hello.

hum...what i was trying to say was that you 'll be able to refresh the 2nd panel when you have a partial postback if you don't set its mode to conditional. knowing this should be enough to make what you need...


Hmm...I'll try..
Obrigado Luis :)
hey, no problem. come back if it doesn't work...

Kerkhoff,

The basic solution is this: on the click event of your button in the second panel, you need to call the update method of your first panel:

this

.UpdatePanel1.Update();

If you want to do this from inside a usercontrol, you will need to throw an event from the usercontrol and then handle it in the parent page. You probably already know this, but to throw an event from your user control, you first need to declare it in your code behind page:

public

eventEventHandler CustomEvent;then, when your button is clicked, you throw the event like this: if (CustomEvent !=null)
CustomEvent(newEventArgs());

In the parent page that contains your control, you just need to handle the event. In Page_Load, you hook up a method:

this

.UcCustomButtonControl.CustomEvent +=newEventHandler(OnCustomButtonClicked);And finally, you write the method to update the panel you want to update:protectedvoid OnCustomButtonClicked(object sender,EventArgs e)
{
this.UpdatePanel1.Update();
}

Hope that's what you needed.Smile
That is exactly what I need =))
thanx...

and...how can I put an UpdatePanel inside my userControl and load it dinamically into anoter update panel? with this.LoadControl("myusercontrol.ascx").

Thanx again :)

No comments:

Post a Comment