943,948 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1678
  • C# RSS
Feb 20th, 2009
0

Calling C# From JS

Expand Post »
I have serached on the internet,I found the links but none of them provide me the solutions.
One of the sites from that I refer-
http://sappidireddy.wordpress.com/20...n-aspnet-ajax/

Code-Behind Page

C# Syntax (Toggle Plain Text)
  1. public partial class _Default : System.Web.UI.Page
  2. {
  3.  
  4. [System.Web.Services.WebMethod]
  5. public static int AddTwoNumbers(Int32 a)
  6. {
  7. int addtion = a + a;
  8. return addtion;
  9. }
  10. }


Source Tab
C# Syntax (Toggle Plain Text)
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7. <title>Untitled Page</title>
  8. <script type ="text/javascript" language ="javascript" src ="JScript.js">
  9. </script>
  10. </head>
  11. <body>
  12. <form id="form1" runat="server">
  13. <div>
  14. <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>
  15. </div>
  16. <table>
  17. <tr>
  18. <td style="width: 100px">
  19. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
  20. <td style="width: 100px">
  21. </td>
  22. <td style="width: 100px">
  23. </td>
  24. </tr>
  25. <tr>
  26. <td style="width: 100px">
  27. </td>
  28. <td style="width: 100px">
  29. </td>
  30. <td style="width: 100px">
  31. </td>
  32. </tr>
  33. <tr>
  34. <td style="width: 100px">
  35. </td>
  36. <td style="width: 100px">
  37. </td>
  38. <td style="width: 100px">
  39. </td>
  40. </tr>
  41. </table>
  42. </form>
  43. </body>
  44. </html>


JS File
C# Syntax (Toggle Plain Text)
  1. function sum(int a)
  2. {
  3. // call server side method
  4. pagemethods.AddTwoNumbers(a);
  5. }

Errors[color=#CC0000]1) Unknown server tag 'aspcriptManager'.
2)Element 'ScriptManager' is not a known element. This can occur if there is a compilation error in the Web site.

Plz help me out.
Similar Threads
Reputation Points: 0
Solved Threads: 8
Posting Whiz
sonia sardana is offline Offline
326 posts
since Mar 2008
Feb 20th, 2009
3

Re: Calling C# From JS

Start by learning how ASP works.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Feb 20th, 2009
0

Re: Calling C# From JS

Start by learning how ASP works.
Reputation Points: 165
Solved Threads: 59
Posting Pro in Training
DangerDev is offline Offline
485 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: how to import data from excel sheets in c#
Next Thread in C# Forum Timeline: Trouble with my IDE. Combobox datasource issue.





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC