Hi,
i have an ASP Page that contains these elements:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="js/page/jquery-1.8.3.js"></script>
<script type="text/javascript">
function Call() {
$.ajax({
type: 'POST',
url: 'Default3.aspx/MyFuction',
data: { name: 'Rasool' },
success: function (data) {
alert(data);
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table border="1" align="center">
<tr>
<td>
<input type="button" name="name" value="Click Me" onclick="Call();" />
<td>
<asp:TextBox runat="server" ID="txt" /></td>
</tr>
</table>
</form>
</body>
</html>
and this is the CodeBhinde of my ASP Page,
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected string MyFunction(string name)
{
return "this is your name : " + name;
}
}
i want to send the Parameter 'name' to MyFunction in CodeBehind, and then return a string value to the Call function (that is a jquery.ajax function), and then the Call function must show the returned value from MyFunction in txt (textbox).
How can I do that?