I am trying to do the page level validation in javascript for and element and if the validation is passed i want to call the codebehind method .cs file method of .aspx.cs file method. Can anyone please provide any details / code which will make this requirement work in an easy way. I am trying to do this in C# .net. Thanks,
-
2what have you done so far.?Sachin– Sachin2013-05-08 12:23:05 +00:00Commented May 8, 2013 at 12:23
-
Have you read anything on form validation in ASP.NET? Learn what is offered in the .NET Framework, and you'll find what you need.CM Kanode– CM Kanode2013-05-08 12:28:54 +00:00Commented May 8, 2013 at 12:28
-
is there are way by which we can call it without jquery?Aditya– Aditya2013-05-08 12:32:50 +00:00Commented May 8, 2013 at 12:32
Add a comment
|
1 Answer
I doubt this is possible...in a direct and easy way. Javascript code is client-side, cs codebehind is server side code.
Usually, the way to "use", or "access" .NET code and methods you need from Javascript (but this applies in general to server-side code) is to expose these methods as a service. Possibly, a REST service or a web-service. See WCF and other frameworks (e.g. ServiceStack) on how to create it. I particularly like ServiceStack; it is simple to use and gets things done in a minute!
A useful list can be found in this answer