[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 400
  • Last Modified:

Calling ASP.NET Function from JavaScript

Is it possible to call a asp.net function from Javascript?
0
Mike_Stevens
Asked:
Mike_Stevens
  • 3
  • 2
1 Solution
 
naveenkohliCommented:
Not direcrtly. You can use AJAX techniques to call back into server into particular function.
0
 
prajeebkumarCommented:
I think another hack would be to have a hidden button and call hiddenbutton.click() in javascript which would call your function... let me know if you want the code to invoke a button click in javascript.
0
 
Mike_StevensAuthor Commented:
I would appreciate some sample code
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
prajeebkumarCommented:
before I try anything, what exactly are you trying to do.. what is the scenario when you want to invoke this asp.net function on client side?
0
 
Mike_StevensAuthor Commented:
I am using javascript to rotate banner ads in the masterpage of a project i am working on.  I am trying to write information on at ad that has just been clicked by the user in an effort to track how many times each ad has been clicked.
0
 
prajeebkumarCommented:
can you have something like this on the click event of your ad image?  you should have a hidden asp:button with click event defined in code behind.. i haven't tried it, but you can give it a shot.

<a href="testURL"    onclick="document.getElementById('hiddenButton').click(); return false;"> <asp:Image id="AdImage"/> </a>

if you can't do this, you can still write to a cookie incrementing the count everytime the user clicks the ad and read from it on page_load and update where you want to, of course you have to implement the logic so that you dont duplicate the count and keep adding it.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

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