Monday, August 11, 2008

How to add service reference dynamically from user control? Microsoft Ajax

First, Create a web page default.aspx and put the html code as following..

<asp:ScriptManager ID="MainScriptManager" runat="server">

Now, Create a usercontrol my first user control

Create a function called AddScriptReference as following...

private void AddScriptReference()
     ScriptManager scriptManger = ScriptManager.GetCurrent(this.Page);
     if (scriptManger != null)
         ServiceReference serviceReference = new ServiceReference();
         serviceReference.InlineScript = false; 
         throw new Exception("Script Manager Not Found");
Then override controls init event as following...

protected override void OnInit(EventArgs e)

Search This Blog
About Me
My Photo

Full Stack Developer, Blogger, Microsoft Mvp, Mentor, Lifelong learner, 12+ Years of Experience for JavaScript, web and Microsoft technologies. ASP.NET MVC/Core, C#, Angular,Vue.js and node.js
Subscribe to my blog


My You tube channel- Please Subscribe
Youtube Video Playlist
My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews