asp.net AJAX Bad Handling of Inline Codeblocks and Multiple Scriptmanagers08/08/2009 02:27 AM
In the "why did they design it this way?" category:
- inline codeblocks (the "<%= %>" syntax) aren't support by MS AJAX calls but the "<%# %>" is supported for repeaters/grids for ajax calls; you have to replace the inline codeblocks with asp:literal's
- if you have multiple ScriptManager tags on a page (e.g., a webpart or control that needs it), instead of ignoring the extra tags, asp.net has to blow up w/ an error stating it isn't allowed; you can work around this by checking whether it's on the page already by following various tips on it, e.g. by doing this:
protected override void OnInit(EventArgs e) { Page.Init += delegate(object sender, EventArgs e_Init) { if (ScriptManager.GetCurrent(Page) == null) { ScriptManager sMgr = new ScriptManager(); Page.Form.Controls.AddAt(0, sMgr); } }; base.OnInit(e); }