amby 0 Light Poster

thanks, problem solved using below string:
data: "{name: '" + $('#Eid').val() + "', phone: '" + $('#phn').val() + "'}",

i have found out that problem is on my server side.

Thanks.

amby 0 Light Poster

Hi, I want to send three text box values to server using jquery ajax. problem is that, i dont know the exact syntax to send three data. When i try sending one data(also change no.of parameters to one at server side method), its going good but when i try to send three text box values, its giving jquery error:"Internal server error". I think I am not sending data in correct way. please somebody tell me how to do that. Example below contains only two sending data, because i was trying to send 2 data first.

Below is the code:

function testCAll() { 
$.ajax({ 
    type: "POST", 
    url: "dbTest1.aspx/SendMessage", 
    data: "{'name': '" + $('#Eid').val() + "', 'phone': '" + $('#phn').val() + "'}", 
    //data: "{'phone': '" + $('#CustomerPhone').val() + "'}", 
    //data: "{'color': '" + $('#ColorId').val() + "'}", 
    contentType: "application/json; charset=utf-8", 
    dataType: "json", 
    success: function(result) { 
        resultData = eval("(" + result.d + ")"); 
        $("#rawResponse").html(concatObject(resultData)); 
    }, 
    error: function(result) { 
        alert("jQuery Error:" + result.statusText); 
    } 
});
amby 0 Light Poster

thanks a lot! it works now. thank u so much

amby 0 Light Poster

thanks but still problem is here. i can show my server code too if it helps u in determining my problem. but server side code is running good when i pass values like this:
data: "{'ntid':'stephen.gilroy1'}",

it only making problem when passing value of input textbox. server side method expects string value as an argument. may be there is the problem, that i have to convert it to string first in the server side method then do any processing. below is my C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
//using System.IO;
//using Newtonsoft.Json;
using System.Web.Script.Serialization;
using System.Web.Script.Services;
using System.Collections;


public partial class Testing : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        al2c00.ldap lp = new al2c00.ldap();

        DataTable dt = lp.GetEmployeeDetailsBy_NTID("650FA25C-9561-430B-B757-835D043EA5E5", "stephen.gilroy1");
        GridView1.DataSource = dt;
        GridView1.DataBind();
    }

    //[WebMethod()]
    //[ScriptMethod()]

    [WebMethod]
    public static string SendMessage(string ntid)
    {
        try
        {
            al2c00.ldap ws = new al2c00.ldap();
            Hashtable htPeople = new Hashtable();

            DataTable dt = ws.GetEmployeeDetailsBy_NTID("650FA25C-9561-430B-B757-835D043EA5E5", ntid);
            
            //Creating StringBuilder array for storing keys
            StringBuilder[] empKeys = new StringBuilder[70];

            for (int i = 0; i < empKeys.Length; i++)
            {
                empKeys[i] = new StringBuilder();
            }

            //Creating stringbuilder array for storing key values
            StringBuilder[] empDetails = new StringBuilder[70];

            for (int i = 0; i < empDetails.Length; i++) 
            { 
                empDetails[i] = new StringBuilder(); 
            }

            //putting datatable data to empKeys and empDetails array
            int inc = 0;
            int j = 0;
            foreach (DataRow dr in dt.Rows)
            {
                    foreach (DataColumn dc in dt.Columns) …
amby 0 Light Poster

i have solved it by putting <br /> instead of "\n" in concatObject method like this: return strArray.join("<br />");

amby 0 Light Poster

Hi, I have a javascript object which is converted from json to java script object. i want to display its values like after each key value pair, i want to insert new line. but i dont know exactly how to do that. below is my code, please take a look and tell me how i should insert a new line. i tried but its not inserting a new line is diplay.

$.ajaxSetup({ 
    cache: false 
    //timeout: 1000000 
}); 
 
//String.prototype.toJSON; 
 
//var the_object = {}; 
 
//function concatObject(obj) { 
//    str = ''; 
//    for (prop in obj) { 
//        str += prop + " value :" + obj[prop] + "\n"; 
//    } 
//    return (str); 
//} 
 
function concatObject(obj) { 
    strArray = []; //new Array 
    for (prop in obj) { 
        strArray.push(prop + ":\t" + obj[prop]+"*******************************************************\"\n\""); 
    } 
    return strArray.join(); 
} 
 
//var input = "stephen.gilroy1"; 
 
function testCAll() { 
    //var input = $('#Eid').val(); 
    //var input = $document.getElementById('Eid').getValue(); 
    //var input = $('input[name=Employee_NTID]').val(); 
    var keyvalue = { 
    //ntid: $('#Eid').val() 
        ntid:"ambreen.haris", 
        name:"ambreen" 
    }; 
    $.ajax({ 
        type: "POST", 
        url: "Testing.aspx/SendMessage", 
        data: "{}", 
        //data: "{'ntid':'stephen.gilroy1'}",       //working 
        //data: {'ntid': $('#Eid').val()}, 
        //data: {keyvalue}, 
        //data: { ntid: $('#Eid').val() }, 
        //data: ({ 'ntid': $('input[name=Employee_NTID]').val() }), 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        success: function(result) { 
            alert(result.d); 
            resultData = eval("(" + result.d + ")"); 
            $("#rawResponse").html(concatObject(resultData)); 
            //$("#response").html(resultData.sn); 
        }, 
        error: function(result) { 
            alert("jQuery Error:" + result.statusText); 
        } 
    }); 
}
amby 0 Light Poster

Hi,
I have to pass string entered in the input text to server method calling through jquery ajax. But its not going through. can please somebody tell me what i m doing wrong here. Below is the code:

$.ajaxSetup({
    cache: false
    //timeout: 1000000
});
function concatObject(obj) {
    strArray = []; //new Array
    for (prop in obj) {
        strArray.push(prop + " value :" + obj[prop]);
    }
    return strArray.join();
}

//var Eid = "stephen.gilroy1";

function testCAll() {
    //var ntid = $('#Eid').val(); 
    $.ajax({
        type: "POST",
        url: "Testing.aspx/SendMessage",
        //data: "{'ntid':'stephen.gilroy1'}",       //working
        data: "{'ntid': $('#Eid').val()}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(result) {
            alert(result.d);
            resultData = eval("(" + result.d + ")");
            $("#rawResponse").html(result.d);
            //$("#response").html(resultData.sn);
        },
        error: function(result) {
            alert("jQuery Error:" + result.statusText);
        }
    });
}

above is js file and below is its aspx file:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Testing.aspx.cs" Inherits="Testing" %>

<!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></title>
    <script src="jquery.js" type="text/javascript"></script>

    <script src="Testing.js" type="text/javascript"></script>
    
    <script src="json2.js" type="text/javascript"></script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Employee's NTID: <input type="text" id = "Eid" name="Employee_NTID" />
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
        <br />
<br />
     <input type="button" onclick="testCAll()" value = "Search"/>
       
       <div id="rawResponse"></div>
       <hr />
       <div id="response"></div>
       
    </div>
    
    </form>
</body>
</html>
amby 0 Light Poster

Thanks a lot!

amby 0 Light Poster

Hi, I am getting this error at runtime: object reference not set to an instance of object

my question is that am i using stringbuilder array correctly here. Because I am new in C#. and i think its the problem with my stringbuilder array. Below is the code:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.Services; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Data; 
using System.Text; 
using System.Web.Script.Serialization; 
using System.Web.Script.Services; 
using System.Collections; 
 
 
public partial class Testing : System.Web.UI.Page 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
 
    } 
 
 
    [WebMethod] 
    public static string SendMessage() 
    { 
        try 
        { 
            al2c00.ldap ws = new al2c00.ldap(); 
            Hashtable htPeople = new Hashtable(); 
 
            //DataTable dt = ws.GetEmployeeDetailsBy_NTID("650FA25C-9561-430B-B757-835D043EA5E5", "john"); 
 
            StringBuilder[] empDetails = new StringBuilder[100]; 
 
 
            string num = "ambreen"; 
            empDetails[0].Append("amby"); 
            num = empDetails[0].ToString(); 
 
            htPeople.Add("bellempposreport", num); 
 
 
            JavaScriptSerializer jss = new JavaScriptSerializer(); 
 
            string output = jss.Serialize(htPeople); 
            return output; 
        } 
        catch(Exception ex) 
        { 
            return ex.Message + "-" + ex.StackTrace; 
        } 
    } 
}

please reply me what i am doing wrong here.

amby 0 Light Poster

.aspx script is running fine. Problem is when i call server method from .ajax. That server method calls web service and convert returning data to json text and send back to java script. that web service is also working fine because i saw its result on page_load method. also i tried return just simple "Hello world" string(after converting it into json) but it gave the same result.

amby 0 Light Poster

one thing i forgot to put in C# file was to write
[WebMethod()] above the sendMessage method.
but still showing the same result:(

amby 0 Light Poster

Thanks airshow for quick reponse. I really appreciate it. when i try datatype: 'json' instead of 'JSON' it is giving parseerror. and when i see raw data using the code u given, it is showing the asp page result in the bottom of the page ( i mean displaying Testing.aspx again in the bottom). u have also seen my C# file in this thread. I also tried sending "hello world" string without convert it to json object but still got the same result. I think in ajax call, url "Testing.asp/sendMessage" is returning the whole script instead of sending just one string "Hello world". I am wondering that if it is calling just Testing.asp and not calling its method sendMessage.

amby 0 Light Poster

Thanks Airshow,
I changed concatObect like yours. using json.decode didnt work but after making some changes to .ajax it is displaying this line given below:

toJSON value :function (key) { return this.valueOf(); }

and changes i have made are:

$.ajax({
            type: "POST",
            dataType: 'JSON',
            //data: "{'ntid':'stephen.gilroy1'}",
            //contentType: "application/json; charset=utf-8",
            //processData: false,
            url: "Testing.aspx/SendMessage",
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            },
            success: function(result, txtStatus, httpRequest) {
                alert(txtStatus);
                the_object = result;
                $('#status').html(concatObject(the_object));
            }

can you please tell me why its not displaying the whole data and if i m using the correct way to display it? please reply me soon. Thanks

amby 0 Light Poster

Hi,
In my code behind file, I called Soap web reference and retreive data and diplay in grid view and it worked. But when I convert retreived data to Json text and send back to java script and on client side, convert json text to java script object and when try to display it, its displaying nothing. I dont know if i m doing something wrong here. please check my code and give me suggestions, I really need help.

Below is the javascript file:

$.ajaxSetup({
    cache: false,
    timeout: 5000
});
var ajax_load = "<img src='loading.gif' alt='loading...' />";

//  load() functions
var loadUrl = "test.txt";

var the_object = {};

function concatObject(obj) {
    str = '';
    for (prop in obj) {
        str += prop + " value :" + obj[prop] + "\n";
    }
    return (str);
}


$(document).ready(function() {
    $("button").ajaxStart(function() {
        alert('Triggered ajaxStart handler.');
    });
    $("button").click(function() {
        $.ajax({
            type: "POST",
            dataType: 'JSON',
            url: "Testing.aspx/SendMessage",
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            },
            success: function(result, txtStatus, httpRequest) {
                alert("success");
                the_object = httpRequest.responseText;
            }
        });
        //alert(concatObject(the_object));
        $('#result').html(concatObject(the_object));

    });
});

and here is code behind file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Xml.Serialization;
using System.Web.Services.Protocols;
using System.Data;
using System.Text;
using System.IO;
using Newtonsoft.Json;


public partial class Testing : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //al2c00.ldap lp = new al2c00.ldap();

        //DataTable dt = lp.GetEmployeeDetailsBy_NTID("650FA25C-9561-430B-B757-835D043EA5E5", "stephen.gilroy1");
        //GridView1.DataSource = dt;
        //GridView1.DataBind();
    }

    public static string SendMessage()
    {
        al2c00.ldap lp = new al2c00.ldap(); …
amby 0 Light Poster

Hi,
I have added web reference using Visual Studio tool i-e Website > add web reference but it add only .disco and .wsdl file. My question is, are these the only 2 files to add? i mean i was expecting .asmx file so that i can see its methods properly. and i wrote code in C# in .aspx.cs(code behind file) which is given below but the error comes saying that invalid web service method name. Check out my code and guide me where i m doing mistake and is that possible to view code of that web service while i can see only .wsdl and .disco file. or tell me that am i going in the right direction or this is not correct way to access Soap web service method. please guide me, i really need help and reply me soon. Below is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Diagnostics;
using System.Xml.Serialization;

using System.Web.Services.Protocols;

public partial class Testing : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    static Example1 obj = new Example1();
    static string s = obj.printDetails("EX76550");

    [WebMethod()]
    //[ScriptMethod()] 

    public static string SendMessage()
    {
        return "Hello World";

        //send message 
    }

    [System.Web.Services.WebServiceBindingAttribute(
     Name = "ldapSoap",
     Namespace = "http://al2c00/ldap")]

    public class Example1 :
             System.Web.Services.Protocols.SoapHttpClientProtocol
    {

        public Example1()
        {
            this.Url = "http://al2c00:45/LDAP/ldap.asmx";
        }

        [System.Web.Services.Protocols.SoapDocumentMethodAttribute(
             "http://al2c00/ldap/GetEmployeeDetailsBy_NTID",
             RequestNamespace = "http://al2c00/ldap",
             ResponseNamespace = "http://al2c00/ldap",
             Use = System.Web.Services.Description.SoapBindingUse.Literal,
     ParameterStyle …
amby 0 Light Poster

Hi,
I have added web reference to my web space but dont know how to call its method from my code behind .aspx.cs file. can somebody please guide me in this matter. Thanks

amby 0 Light Poster

Hi,
I am now using .aspx.cs file for method but still getting the same error. i m new to web development. please somebody help me in code and give me correct guidance. Thanks

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
     //using System.Web.Services; 
    [WebMethod()] 
    //[ScriptMethod()] 

    public static string SendMessage(string subject, string message, string messageId, string pupilId) 
    {
        return "Hello world";

        //send message 
    } 
}

and .js file is now:

$.ajaxSetup({
    cache: false
});
//var ajax_load = "<img src='loading.gif' alt='loading...' />";

//  load() functions
//var loadUrl = "test.txt";

$(document).ready(function() {
$('.start').ajaxStart(function() {
        alert('Triggered ajaxStart handler.');
    });
    $("button").click(function() {
    //$("p").html(ajax_load).load(loadUrl);
    //var eNtid = $("#Eid").val();
    $.ajax({
        type: "POST",
        url: "userNTID.aspx/SendMessage",
        //data: ("Employee NTID :" + eNtid),
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        },
        success: function(result) {
            alert("success"+result);
        }
    }); 


    });
});
amby 0 Light Poster

Hi,
I am calling web service through jquery ajax call for the first time and getting an error. Can please somebody help me in this i would really appreciate it. Below is the code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="userNTID.aspx.cs" Inherits="Default2" %>

<!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></title>

    <script src="jquery.js" type="text/javascript"></script>

    <script src="JScriptuserNTID.js" type="text/javascript"></script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
Employee's NTID: <input type="text" id = "Eid" name="Employee_NTID" />
<br />
<br />
    <button type = "button" id = "callingMethod" class ="start">Search</button> 
    </div>
    </form>
</body>
</html>

Here is JScriptuserNTID.js file:

$.ajaxSetup({
    cache: false
});
//var ajax_load = "<img src='loading.gif' alt='loading...' />";

//  load() functions
//var loadUrl = "test.txt";

$(document).ready(function() {
$('.start').ajaxStart(function() {
        alert('Triggered ajaxStart handler.');
    });
    $("button").click(function() {
    //$("p").html(ajax_load).load(loadUrl);
    //var eNtid = $("#Eid").val();
    $.ajax({
        type: "POST",
        url: "./WebService.asmx/HelloWorld",
        //data: ("Employee NTID :" + eNtid),
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(textStatus);
        },
        success: function(result) {
            alert("success");
        }
    }); 


    });
});

Here is WebService.asmx/HelloWorld:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
 [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public void HelloWorld() {
        Console.WriteLine( "Hello World" );
    }
    
}
amby 0 Light Poster

Thanks, its working now

amby 0 Light Poster

hey i am new in javascript, i was having problem in including jquery in this file in Visual Studio but i resolved it by using ResolveUrl but after that its giving error "; expected" in the line1 i-e

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2"%>

<!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></title>
    <script type="text/javascript" src="<%=ResolveUrl"jquery.js"%>"></script> 
    
<script type="text/javascript" src="<%=ResolveUrl"JScript.js"%>"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <p>Hello world</p>
    <p>I am Ambreen Haris</p>
<p id = "testpara">everything is going good</p>
<button type = "button">click me</button>
<button id = "button2" type = "button">click to see ajax result</button>
    </form>
</body>
</html>

can somebody help me that what i am missing in where? external javascript file is here:

$(document).ready(function() {
    $("button").click(function() {
        $("p:first").toggle();
    });
    $("button#button2").click(function() {
        $("p#testpara").toggle();
        $.ajax({
            type: "GET",
            url: "C:\Program Files\Notepad++\tryit.js",
            dataType: "script"
        });
    });
});

thanks in advance

amby 0 Light Poster

Hi, i just start learning jquery and want to see some exapmle of jquery core API and ajax. can somebody please give me some code example so that it can be easy for me to understand.

Thanks in advance.

amby

amby 0 Light Poster

hey thanks a lot
it worked..... thanks for your guidance....i really appreciate your help
amby

amby 0 Light Poster

hi there
can anybody please help me out....i just start learning asp.net and have downloaded visual web developer 2008 Express Edition....and it opens my .aspx file.....but i want to check its contents on my browser.....i wrote the simple program that prints Hello world in the center with the yellow background.....first i saved this file as .html and opened it successfully with my browser.....then i saved it as .aspx and it display the entire code instead of giving output like html did
i m using Windows XP and have Microsoft .NET framework 1.1, 2.0 with SP2, 3.0 with SP2, 3.5 with SP1 and have Microsoft Windows SDK for visual studio 2008 SP1 Express tools for .NET framework.....i also put check in front of IIS in add/remove windows component but still nothing happen:( ....i m using IE 7.0....i will be very grateful to u if u can guide me what to do.....because i m new in asp.net.....

thanx in adance

amby

amby 0 Light Poster

actually i have already used RS232 port with that hardware and that is working too.....but i need to interface with usb because this is objective of our project....have u ever used windriver software for usb interfacing? and do u have any idea about that?

amby 0 Light Poster

i m using PIC 16C745 microcontroller for usb interfacing.....and my hardware sends data from port pins of microcontroller 18C52 to 16C745.....and then to usb port........i want to perform operations on data coming from usb port....i mean i want to access that buffer containing data coming from usb port.....if u have any idea about this then please tell me...i have to perform this work in a week...and i m so worried

amby 0 Light Poster

hey can anybody help me.. i want to interface my hardware with the PC through usb port.... and my application program is written in vb6.0...so do i need WIN DRIVER type software for low level programming and then call win driver libraries in vb 6.0 or else? can somebody send some sample code in vb6.0 for this that can help me?...thanx in advance

amby 0 Light Poster

thanx themaj thanx alot!!
the syntax u provided gave same result which i want......sorry for late replying....i m checking my mail after a long time.......anywez thanx again for ur help..

amby 0 Light Poster

i want to convert string into byte....this can be done in vb.net..can somebody help me in doing this in vb6.0..here the simple code..

Private Sub Form_Load()
Dim str1 As String
Dim i As Byte
i = CByte(Val(str1))
Text1.Text = i
End Sub

but this code still not able to convert string into byte....and still giving type mismatch error....i m unable to solve this small problem

amby

amby 0 Light Poster

i want to send the right click sub routine that i've formulated, through send message funtion to windows in vb.net so that it can work same as normal right click does what i am doing is

Public Sub RightClick()
RightDown()
RightUp()
End Sub

Public Sub RightDown()
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
End Sub

Public Sub RightUp()
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
End Sub


Public Sub ClickButton(ByVal ButtonHandle As IntPtr)

'send the right mouse button "down" message to the button...
Call SendMessage(ButtonHandle, MOUSEEVENTF_RIGHTDOWN, 0, IntPtr.Zero)

'send the right mouse button "up" message to the button...
Call SendMessage(ButtonHandle, MOUSEEVENTF_RIGHTUP, 0, IntPtr.Zero)

'send the button state message to the button, telling it to handle its events...
Call SendMessage(ButtonHandle, BM_SETSTATE, 1, IntPtr.Zero)


Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
RightClick()
ClickButton(Windows.Forms.MouseButtons.Right)
'MessageBox.Show("show")
End Sub


please help me where i am going wrong

amby 0 Light Poster

can somebody please help me to write a code so that mouse pointer can move around on the desktop according to program..for example it is moving in up direction when i give '1' to any variable. and it is moving in down direction when i give '2' to any variable