0

There is a function in a class file name "User" in App_Code file. I need to access a function in the class

public static string GetUserRole(string returnValue)

from javascript which is placed in a seprate .js file in the folder name "js"

Please help

4
  • var roleName = Users.GetUserRole("RoleName"); Commented Oct 18, 2011 at 19:57
  • But this is providing me error. I need to get the return value from the function, please help Commented Oct 18, 2011 at 19:58
  • Exactly what is the context for this? Where is the JavaScript running, exactly? Commented Oct 18, 2011 at 19:58
  • There are some validation already exists in the .js file, I need to append them based on the rolename. This .js file is placed in the JS folder. Commented Oct 18, 2011 at 20:00

2 Answers 2

1

The simplest way to accomplish this is to utilize page methods. I better way is to use a web services or expose the function though some type of http get method or a web service .

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

2 Comments

Creating a web service will be difficult for me, because my boss don't want to go into creating other files for this. Can you help me with other solution, if possible. +1 for your quick answer.
Search for page methods javascript tutorial and you will find answers a plenty.
1

[WebMethod] public static string GetUserRole(string returnValue)

This guy explains it pretty good and has an example. http://decoding.wordpress.com/2008/11/14/aspnet-how-to-call-a-server-side-method-from-client-side-javascript/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.