hi
can any one tell me how can i call asp.net method from javascript function
Call asp.net method from javascript function
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
rakesh chaudhari57 reputationPosted Jul 10, 2012, 3:21 AM EDT
firstly add this header file in code behind
using System.Web.Services;
[System.Web.Script.Services.ScriptMethod(UseHttpGet = true)] // httpget isn't necessary but often a good idea
[System.Web.Services.WebMethod(true)]
public static string CallCodeBehind(string argID)
{
return strErrormsg;
}
this is the asp.net function
and just it call as
on u r button
onclick="return CallCodeBehind('argument value')"
add this and get u r output
Have a happy coding