PermaLink 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);
}


Comments :v
No comments.
Start Pages
RSS News Feed RSS Comments Feed CoComment Integrated
The BlogRoll
Calendar
March 2024
Su
Mo
Tu
We
Th
Fr
Sa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Search
Contact Me
About Ken
Full-stack developer (consultant) working with .Net, Java, Android, Javascript (jQuery, Meteor.js, AngularJS), Lotus Domino