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,
Asked
Active
Viewed 1,503 times
-9
-
2what have you done so far.? – Sachin May 08 '13 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 May 08 '13 at 12:28
-
is there are way by which we can call it without jquery? – Aditya May 08 '13 at 12:32
1 Answers
2
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

Community
- 1
- 1

Lorenzo Dematté
- 7,638
- 3
- 37
- 77