C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » ASP.NET/Web Applications »

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


Posted Date: 05 Dec 2008    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: DotNetJapsMember Level: Gold    
Rating: 1 out of 5Points: 4



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

---------------------------------------------------------------------------


--------------------------------------------------------------------------

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.Path="~/MyWebService.asmx";
serviceReference.InlineScript = false;
scriptManger.Services.Add(serviceReference);
}
else
{
throw new Exception("Script Manager Not Found");
}
}
'--------------------------------------------------------------------------
Then override controls init event as following...

'--------------------------------------------------------------------------
protected override void OnInit(EventArgs e)
{
AddScriptReference();
base.OnInit(e);
}
'--------------------------------------------------------------------------


For more details, visit http://jalpesh.blogspot.com/




Responses

Author: ChandraShekar Thota    03 Jan 2009Member Level: Diamond   Points : 0
Good

Chandrashekar Thota(Editor, MVP)


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
How to add service reference dynamically from user control? Microsoft Ajax  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Adding Colored Items to Dropdown Using Javascript and Change Page Background
Previous Resource: Handling concurrent AJAX requests
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use