I am trying to implement ajax functionality in SP 2010 Visual web part through Updatepanel/ScriptMgr from Asp.net Ajax lib.
When I try to add the UpdatePanel through code or server tags it throws me the following error:
“The control with ID 'thePanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it”
When I add the script manager through code or server tags, I ran into the following issues.
Please let me know if I miss something.
Neither of the snippets are working…
protected override void CreateChildControls()
{
base.CreateChildControls();
var panel = new UpdatePanel { ID = "thePanel" };
//Important: UpdateMode MUST be Conditional in a webpart to prevent conflicts with the ribbon.
panel.UpdateMode = UpdatePanelUpdateMode.Conditional;
var button = new Button { ID = "theButton", Text = "Click Me" };
button.Click += ButtonClick;
TheLabel = new Label { ID = "theLabel" };
Control template = panel.ContentTemplateContainer;
template.Controls.Add(button);
template.Controls.Add(TheLabel);
Controls.Add(panel);
}
( Or )
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblTest" runat="server" />
<asp:Button ID="btnsubmit" Text="Submit" OnClick="btnClick_Handler" runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>
REPLY :1
.ascx
<asp:PlaceHolder ID="sMgr_place" runat="server" />
<asp:UpdatePanel runat="server" OnInit="updatePanel_Init">
<ContentTemplate> ... </ContentTemplate></asp:UpdatePanel>
.ascx.cs
public void updatePanel_Init(object sender, EventArgs e)
{
if (ScriptManager.GetCurrent(Page) == null)
{
ScriptManager sMgr = new ScriptManager();
sMgr.EnablePartialRendering = true;
sMgr_place.Controls.Add(sMgr);
}
}
Check this
Note : Provide your comments by clicking below options! Thanks ! :)
You have to add the script manager in master page. You may want to refer the below link.
பதிலளிநீக்குhttp://sharemypoint.wordpress.com/2007/11/10/webpart-and-ajax-tricks-on-creating-scriptmanager/