TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
viv verma
NA
163
35.2k
how to call webmethod with parameter
Nov 18 2016 2:55 PM
<asp:Label ID="Label1" runat="server" Text="2 Js call">HHHH
<asp:Label ID="Label2" runat="server" Text="">
// show1() and show2() call in Label1//
========================================================================
function show1() {
var lb = document.getElementById('Label1').innerHTML;
document.getElementById("Label2").innerHTML = lb;
}
function show2() {
$.ajax({
type: "POST",
url: "JS2.aspx/GetCurrentTime",
data: '{name: "' + document.getElementById("Label2").innerHTML + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
============================================================
[System.Web.Services.WebMethod]
public static string GetCurrentTime(string name)
{
return "Hello " + name + Environment.NewLine + "The Current Time is: "
+ DateTime.Now.ToString();
}
===============================
PROBLEM is here
data: '{name: "' + document.getElementById("Label2").innerHTML + '" }'
I did not pass Label2 value here , so its show undefiend.Pls help me
Reply
Answers (
3
)
Through hidden field value how to bind gridview in ASP.NET
how to get value Table's or Gridvie tr td from Jquery,