Click here to Skip to main content
12,698,292 members (22,911 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET Javascript
my code is like this
<HTML>
<HEAD>
<script type="text/javascript" language="JavaScript">
function alertMe() {
var box = document.getElementById("myTextBox");

-------------------------------------------------------
}
</script>
</HEAD>
<BODY>
<INPUT type="text" id="myTextBox"  önkeyup="alertMe()">
</INPUT>


Initial Contents of the div 'logBox'

</BODY>
</HTMl>



in the ----------------------------------- i need to call a c# function can any one suggest me with examples....
Posted 8-Sep-11 20:46pm
Updated 8-Sep-11 22:20pm
Dalek Dave433.3K
v3
Comments
Dalek Dave 9-Sep-11 3:21am
   
Edited for Code Block.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Please refer my article related to the same, use JQuery instead of javascript and will be easy to implement

Calling C# method using JQuery client side[^]

Use can even look at the alternate solution

Calling a C# method using jQuery on the client side[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Please follow below any item:

1. Write a function in code behind with public/protected modifier and then call as below:
<%= YourCodeBehindFunctionName() %>


2. If you want to call a function from your business layer then call the function as, the function must be static:
<%= NamespaceName.ClassName.YourFunctionName() %>
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

    <%=nameOfTheFunction()%>
  Permalink  
Comments
Kartheek.chakrala 9-Sep-11 4:37am
   
please fulfill ur answer? with an example. ur answer is valued to me..
hilmisu 9-Sep-11 4:44am
   
in your function (with the one in javascript)

function alertMe() {
var box = document.getElementById("myTextBox");

<%=nameOfTheFunction()%> //this function is in your c# side which you wanted to call.
}

This is simple and usefull to call a c# side function in your javascript.
Member 8090436 24-Jul-12 12:40pm
   
Not able to call..it says 'name 'functionname' does not exists in the current context.'
I tried but failed :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 3 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100