Click here to Skip to main content
11,709,844 members (77,359 online)
Rate this: bad
good
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 19:46pm
Edited 8-Sep-11 21:20pm
Dalek Dave433.2K
v3
Comments
Dalek Dave at 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 at 9-Sep-11 4:37am
   
please fulfill ur answer? with an example. ur answer is valued to me..
hilmisu at 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 at 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
0 Sergey Alexandrovich Kryukov 524
1 OriginalGriff 250
2 Peter Leow 229
3 Maciej Los 180
4 Mika Wendelius 125
0 OriginalGriff 9,428
1 Sergey Alexandrovich Kryukov 9,037
2 CPallini 5,189
3 Maciej Los 4,991
4 Mika Wendelius 3,856


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 3 Oct 2011
Copyright © CodeProject, 1999-2015
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