What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 12079 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > ASP.NET AJAX > Use of PageMethods ...
Rajni.Shekhar

Use of PageMethods

 Code Snippet posted by: Rajni.Shekhar | Posted on: 4/18/2012 | Category: ASP.NET AJAX Codes | Views: 574 | Status: [Member] | Points: 40 | Alert Moderator   


Add Reference of AjaxControlToolkit.dll

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc2" %>
<!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></title>
<script language="javascript" type="text/javascript" src="JScript.js"></script>
</head>
<body onload="load();">
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="scrMgr" runat="server" EnablePageMethods="true"></asp:ScriptManager>

</div>
</form>
</body>
</html>


Default.aspx.cs

using System;

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static String AlertMsg(string strMessage)
{
return strMessage;
}
}


JScript.js


function load() {

PageMethods.AlertMsg("dot net funda!!", OnSuccess, OnFail);
}

function OnSuccess(val) {
alert(val);
}

function OnFail() {
alert("fail");
}


Thanks,
Rajni Shekhar
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/22/2013 12:20:28 AM