How to properly reference a user control and dynamically add it to page?

how to add a reference to the master page script manager, from the user control?

  • I have a ScriptManager which is added to my MasterPage; <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true" /> I have a Web User Control which is placed on the master page. Inside the web user control, I'd like to use PageMethods but it complains that PageMethods is not defined. function ddlSqlConnections_SelectedIndexChange(selectedValue) { PageMethods.OnSelectedIndexChanged(selectedValue); location.reload(true); } I added a new ScriptManager to the user control and it complained that only one scriptmanager can exist on one page so basically how to add a reference to the master page script manager, from the user control? It doesn't seem to be possible? Thanks,

  • Answer:

    Use a regular ScriptManager instead of the RadScriptManager: <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />

The Light at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

My conclusion was it's not possible with a Web User Control Page Method and I used AJAX with web service instead: $('.ddlSqlConnections').change(function (control) { var selectedValue = control.currentTarget.value; if (selectedValue == 0) { return; } $.ajax({ type: "POST", url: "AdminService.asmx/AdminConnectionsOnSelectedIndexChanged", data: "{uniqueName: " + selectedValue + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { location.reload(true); }, error: function (msg) { alert('failed to send a web service request; please contact the administrator.') } }); });

William

You could try to Invoke a method in your masterpage from your userconrol. Page.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod, null, this.Page, new object[] { });

Jimmy Mattsson

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.