Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 757
  • Last Modified:

How to call javascript methods in .js file manually from .aspx.cs file (c#)

I have a C# VS .NET 2.0 project.
All the js code is in a .js file.
In the code behind (testPage.aspx.cs), we add methods from the .js file to the asp controls. For instance, we have a radio button: rbTestButton. In the code behind, we add the OnClick attribute using a method in the .js file:
rbTestButton.Attributes.Add("OnClick", "jsMethodFromJsFile()").
so whenever rbTestButton is clicked, method jsMethodFromJsFile() executes.

I want to call this method manually from the code behind. Is this possible?

1 Solution
No, because Javascript is executed on the client side. Execution in .NET is on server end.

If you describe what you are trying to accomplish, someone may be able to assist you further.
fippifAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now