0 Replies - 2354 Views - Last Post: 19 February 2009 - 12:40 PM Rate Topic: -----

#1 mansi sharma   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 19-February 09

Calling C# Function from Js

Posted 19 February 2009 - 12:40 PM

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....in-aspnet-ajax/



Mine Code as below-
[b]Code Behind Page Code-[/b][color=#CC0000]
public partial class _Default : System.Web.UI.Page
{
	
	[System.Web.Services.WebMethod]
	public static int AddTwoNumbers(Int32 a)
	{
		int addtion = a + a;
		return addtion;
	}
}




[b]Source Tab Code[/b][color=#CC0000]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
	<title>Untitled Page</title>
	<script type ="text/javascript" language ="javascript" src ="JScript.js">
	</script>
</head>
<body>
	<form id="form1" runat="server">
	<div>
	<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>
	</div>
		<table>
			<tr>
				<td style="width: 100px">
					<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
				<td style="width: 100px">
				</td>
				<td style="width: 100px">
				</td>
			</tr>
			<tr>
				<td style="width: 100px">
				</td>
				<td style="width: 100px">
				</td>
				<td style="width: 100px">
				</td>
			</tr>
			<tr>
				<td style="width: 100px">
				</td>
				<td style="width: 100px">
				</td>
				<td style="width: 100px">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>




[b]JS File[/b][color=#CC0000]
function sum(int a)
 {	 
		// call server side method
	 pagemethods.AddTwoNumbers(a);
   }





Errors[color=#CC0000]1) Unknown server tag 'asp:ScriptManager'.
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.

Is This A Good Question/Topic? 0
  • +

Page 1 of 1