-9

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,

3
  • 2
    what have you done so far.? Commented 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. Commented May 8, 2013 at 12:28
  • is there are way by which we can call it without jquery? Commented May 8, 2013 at 12:32

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.