Click here to Skip to main content
15,913,027 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: accessing to a control from other pages Pin
VenkataRamana.Gali30-Aug-07 1:46
VenkataRamana.Gali30-Aug-07 1:46 
GeneralRe: accessing to a control from other pages Pin
Urs Enzler30-Aug-07 7:18
Urs Enzler30-Aug-07 7:18 
QuestionSecond Post but no Reply (Webservice in Firefox) Pin
Abubakarsb29-Aug-07 23:39
Abubakarsb29-Aug-07 23:39 
AnswerRe: Second Post but no Reply (Webservice in Firefox) Pin
Sathesh Sakthivel29-Aug-07 23:49
Sathesh Sakthivel29-Aug-07 23:49 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb29-Aug-07 23:56
Abubakarsb29-Aug-07 23:56 
AnswerRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync29-Aug-07 23:58
Michael Sync29-Aug-07 23:58 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 0:10
Abubakarsb30-Aug-07 0:10 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync30-Aug-07 0:38
Michael Sync30-Aug-07 0:38 
Javascript (How to call .NET Web Service from pure javascript)

var req;
       var isIE;

       function initRequest() {
       if (window.XMLHttpRequest) {
       req = new XMLHttpRequest();
       } else if (window.ActiveXObject) {
       isIE = true;
       req = new ActiveXObject("Microsoft.XMLHTTP");
       }
       }

       //url will be Web Service URL.

       function CallWebService(url,params) {

       initRequest();

       req.onreadystatechange = processRequest;
       req.open("POST", url, true);
       if(params!=null)req.setRequestHeader("Content-length", params.length);
       req.setRequestHeader("Connection", "close");
       req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
       req.send(params);
       }

       function processRequest() {
       if (req.readyState == 4) {
       if (req.status == 200) {
          var message = req.responseXML; //Result in XML.
       }
       }
       }



HTML (How to call Javascript function )

<input type="button" value="Call .NET Web Service!" onclick="CallWebService('http://localhost:2943/WebSite1/WebService.asmx/testWebService1',null)" />
<br //>
<input type="button" value="Call .NET Web Service with parameters!" onclick="CallWebService('http://localhost:2943/WebSite1/WebService.asmx/testWebService2','a=Michael&b=5')" //>

Web Service

using System;<br />
using System.Web;<br />
using System.Collections;<br />
using System.Web.Services;<br />
using System.Web.Services.Protocols;<br />
<br />
<br />
/// <summary><br />
/// Summary description for WebService<br />
/// </summary><br />
[WebService(Namespace = "http://tempuri.org/")]<br />
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
public class WebService : System.Web.Services.WebService {<br />
<br />
    public WebService () {<br />
<br />
        //Uncomment the following line if using designed components <br />
        //InitializeComponent(); <br />
    }<br />
<br />
    [WebMethod]<br />
    public string testWebService2(string a,int b) {<br />
        return "Hello World " + a + " - " + b.ToString();<br />
    }<br />
<br />
    [WebMethod]<br />
    public string testWebService1()<br />
    {<br />
        return "Hello World ";<br />
    }<br />
    <br />
}<br />
<br />


Hope it helps.. If it is helpful for you, please vote the message. Thanks.

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)

If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. Smile | :)

GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync30-Aug-07 0:41
Michael Sync30-Aug-07 0:41 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 2:32
Abubakarsb30-Aug-07 2:32 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync30-Aug-07 3:08
Michael Sync30-Aug-07 3:08 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 3:57
Abubakarsb30-Aug-07 3:57 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 4:34
Abubakarsb30-Aug-07 4:34 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 4:45
Abubakarsb30-Aug-07 4:45 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync30-Aug-07 5:21
Michael Sync30-Aug-07 5:21 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 11:49
Abubakarsb30-Aug-07 11:49 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync30-Aug-07 15:19
Michael Sync30-Aug-07 15:19 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb31-Aug-07 0:32
Abubakarsb31-Aug-07 0:32 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync31-Aug-07 5:36
Michael Sync31-Aug-07 5:36 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Michael Sync2-Sep-07 16:24
Michael Sync2-Sep-07 16:24 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 1:31
Abubakarsb30-Aug-07 1:31 
GeneralRe: Second Post but no Reply (Webservice in Firefox) Pin
Abubakarsb30-Aug-07 1:33
Abubakarsb30-Aug-07 1:33 
QuestionRegular expression Pin
Mr.Sam29-Aug-07 23:35
Mr.Sam29-Aug-07 23:35 
AnswerRe: Regular expression Pin
Imran Khan Pathan30-Aug-07 0:27
Imran Khan Pathan30-Aug-07 0:27 
Questionhow to call function Pin
kuwl_mark29-Aug-07 23:15
kuwl_mark29-Aug-07 23:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.