Wednesday, March 21, 2012

Loading asynchroneously a webcontent from a menu

Hi

I have a menu on a masterpage. I would like the webcontent asynchroneously loaded when I click on the menu

I placed anUpdatePanel on theWebContent and a trigger targeted on the Menu.MenuItemClick event.

This is the test code:

protectedoverridevoid OnPreInit(EventArgs e)

{

base.OnPreInit(e);MasterPage Master =this.MasterasMasterPage;

Microsoft.Web.UI.AsyncPostBackTrigger trigger =newAsyncPostBackTrigger();

trigger.ControlID = Master.MyMenuID;// get Menu.ID

trigger.EventName ="MenuItemClick";

this.UpdatePanel1.Triggers.Add(trigger);

}

But this does not work at all.

Is there any way to do this?

thank you

Hi,

Please refer to this documentation:

http://ajax.asp.net/docs/mref/T_System_Web_UI_AsyncPostBackTrigger.aspx

Programmatically adding AsyncPostBackTrigger controls is not supported. Use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.

Hope this helps.

No comments:

Post a Comment