.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

return class to javascript from webservice?

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
Hi,I know i've seen a tutorial for this, but can't locate it anymore. I have a class Employee in c# side, I also have a webservice where I pass in an ID# and an Employee object is returned. Now I want this object returned to Javascript code, I know I've seen it done before, can someone point me to a tutorial that shows something like this being done. I'm using the MicrosoftAjax.js file.Thanks.

View Complete Post

More Related Resource Links

[newbie] How to return a data record from a webservice (wsdl)?



vs2010, .NET 4.0

I have a webmethod which I want to return a data record (for example: name, surename, address, age, zip etc)

I wonder how to accomplish this. I think the solution is about creating an object which contains all the records serialized. And then the webmethod returns this serialized object. I'm not 100% sure how to accomplish this, if some of you good provide me with some tips, tutorial or link to an article explaining it, that would be great

How do I generate proxy class for webservice with no WSDL published?

 Hello, I need to utilize following web service: https://www.icds.att.com/xmlrequest Service publishes 2 XML files (one for Request and another for Response) https://www.icds.att.com/schemas/XMLRequest.xsd and https://www.icds.att.com/schemas/XMLResponse.xsd. I generated classes for those manually, but my question is how do I actually utilize web service (generate proxy file) in this case. Do I have to code everything manually?

Writing Webservice return values to table within SQL CLR

Visual Studio 2010/Sql Server 2005/ .net 3.5/ C# I have compiled and created assemblies and all works fine when all I do is .pipe.send.   I have changed it now to capture the values in local parameters so I can write to a sql table on the same server.  I have the connection to the database and the table created.  The code compiles fine but when I run it from sql I get the following error.  The code follows the error.   Msg 6522, Level 16, State 1, Procedure CventSP, Line 0 A .NET Framework error occurred during execution of user-defined routine or aggregate "CventSP": System.Data.SqlClient.SqlException: Incorrect syntax near '@eventtitle'. System.Data.SqlClient.SqlException: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnectionSmi.EventSink.DispatchMessages(Boolean ignoreNonFatalMessages) at Microsoft.SqlServer.Server.SmiEventSink_Default.DispatchMessages(Boolean ignoreNonFatalMessages) at System.Data.SqlClient.SqlCommand.RunExecuteNonQuerySmi(Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at StoredP

JavaScript Unable To Reload On UpdatePanel Asynchrouns Return

I have a simple code that sets the text of a Literal Control to a javascript I want it to run on each asynchronous request.But, the javascript runs only in the first request. The .cs and .aspx code are listed belo:javaScriptUpdatePanel.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="javaScriptUpdatePanel.aspx.cs" Inherits="userControlRepository.javaScriptUpdatePanel" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">        <asp:ScriptManager ID="ScriptManager1" runat="server">        </asp:ScriptManager>        <asp:UpdatePanel ID="UpdatePanel1" runat="server">                        <ContentTemplate>                &nbs

Load Javascript/CSS from C# Class Library

Can anyone help me figure out how to load Javascript/CSS from my Class Library onto my .aspx pages? Is it possible?Thanks

Referenced WebService, class constructor with parameters

Hi, I have WebService which is referenced in C# ClassLibrary project. In WebService project I have a class named User, which has two constructors - one without parameters and one whith parameters. When I try to create instance of User class from WS in ClassLibrary, I can use only constructor with parameters. My question is, how can I use in constructor with parameters like User u = new User("some@email.com", ...);. Any idea? Thansk

return false in javascript



<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="changeText(); return false;" />
<script type="text/javascript">
<script type="text/javascript"> function confirmDelete() { if (confirm("Yes")) return true; else return false; }
Here in both cases what will return false do
function confirmDelete()

how to apply a css class on html span tag in javascript?



I'm trying to apply a css class on an html span tag in javascript, like below-

$('#company-info').css("class", "help");

But this line of code isn't working!

Can anyone let me know the right way of doing this?



WCF calling webservice - assigning return value taking a long time

0 down vote favorite

I have a wcf service (WCF_A ) which calls another wcf service (WCF_B) (currently I am hosting the WCF_B on my local machine with my credentials – as windows service), WCF_B internally makes a call to a webservice (WS01) that is hosted on the IIS. I have created a test client and call the WCF_A -> WCF_B -> WS01. Just before making the call to (WS01) I start a timer and I stop the timer when the webservice call comes back and the result is assigned to a variable, the flow is as below WCF_B

1)  Debug.WriteLine(“Call to webservice”) 
2)  Starttimer 
3)  Var result = WS01.Function(xxxx) 
4)  Stop

Determine CSS class, set by javascript, server-side


 I have a website and I use javascript/jQuery to change the CSS classes associated with various controls on the page to hide and displey them based upon user selections.  I want to be able to determine the current Css class for an item on my page when the page is posted back to the server.  Is there any way to determine the current Css class for a control on the server when it's been changed using javascript client-side?

Any suggestions would be greatly apprciated.



Capture large text return from Javascript function


I have a Javascript function that writes a large scale of text into a div for now, but then I need to capture the text and use it in code behind. I tried to use hidden field but it has size limit so it didn't work.  The text is shown in the page, but when I view source, there is no text in the div so I couldn't use code behind to read the text from the div even though runat is server because the text is always empty. Any suggestions? Thanks!!!

I have my insert logic in my class, how do i output the return value on my page to use with another


I have the following portion in my class, i need to get the value of the inserted record so i can use in another insert that im doing with a loop, so i need to add another variable to my

"public void insertServ( string EmLogin, string EmPass, int Emnum )"  the procedure is already returning the value i need, just need to get it back on the page so i can use it with my next insert.



                cmd.Parameters.Add("@EmLogin", System.Data.SqlDbType.VarChar).Value = EmLogin;
                cmd.Parameters.Add("@EmPass", System.Data.SqlDbType.VarChar).Value = EmPass;
                cmd.Parameters.Add("@EmNum", System.Data.SqlDbType.Int).Value = EmNum;

                cmd.Parameters["id"].Direction = ParameterDirection.ReturnValue;

            catch (System.Data.SqlClient.SqlException ex)
                string msg = "Server Email Insert Error:";
                msg += ex.Message;
                throw new Exception(msg);


How to use webservice in Class Library Project


I've created class library project and added service reference to  webservice.
When i try to use webservice object am not able to access webservice methods.

myservice proxy=new myservice();

proxy.( no methods are coming)?

jQuery / javascript calling a webservice


I've tried a bunch of different examples and still can't get this to work.

I have a jQuery GalleryView control I'm using and I simply want to log impressions.  I set up a webservice that works, but I can't figure out how to get it to work in javascript.  I have verified that the webservice is working as expected.

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptServ

How can i return a value from a simple WebForm.aspx to javascript code.


Hi Experts.

How can solve this problem; Suppose you write a simple JavaScript code in form tag like this:

<script  language="javascript">

                Var type="100";

                Var result = ';

Var iframe = '<iframe src="WebForm1.aspx?"t=' + type + '"></iframe>';

Document.write(iframe);           // call WebForm1.aspx in iframe tag

Document.write(result);            //write the result that return from WebForm1.aspx


I want return the value from WebForm1.aspx and save it in result variable. How can I do?How can i return a value from WebForm1.aspx and save it in result variable?

With Regards.Mojtaba

SSRS 2008 Web Service Datasource doesn't return embedded class



I am building reports with SSRS 2008 using web services as datasource.

Let me explain my design:

I have 2 classes:

public class Employee

{ public string fname;

public string lnamel;

public Department dept;


public class Department

{public string name;


i have this function as a web method:

public Employee GetEmployee(string lastname)

      Employee emp = new Employee();
      // I query the DB and return the result in a datatable
     // I then bind the table fields to my Employee object
     return emp;


When I test the service, it return the employee's info and his/her dept info as well.

But when i test the dataset in the report, it only return the employee's info and not the department info.

Any suggestion?

Thanks a lot!!!

how to connect webservice from javascript in asp.net


i want to connect webservice from javascript and pass the parameters.help me


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend