Click here to Skip to main content
Sign Up to vote bad
good
See more: C#jQuery
Suppose you have a page named Default.aspx. On this page there is a
Click here to see data comming from page method
. You want to show date in this div from a method in code file.
In Default.aspx.cs make a Method like this.
add following namespace.
 
using System.web.services;
 
[WebMethod]
public static string GetData()
{
return "Pakistan Zindabad";
 
}
//write this code on Default.aspx head section.
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
 
$("#div1").click(function () {
 
$.ajax({
type: "POST",
url: "default7.aspx/GetData",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {

$("#div1").html(msg.d);
 
}
 
});
});

/script>
 
This solution is working fine.
Posted 26 Apr '12 - 7:40

Comments
Wes Aday - 26 Apr '12 - 14:06
Reason for my vote of 1 This is not a question

1 solution

This looks like a Tip that you want to share with others.
 
Post here as a Tip/Trick: Publish Tip/Trick here on CodeProject[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 399
1 Mahesh Bailwal 353
2 Maciej Los 270
3 CPallini 245
4 Rohan Leuva 175
0 Sergey Alexandrovich Kryukov 9,162
1 OriginalGriff 7,194
2 CPallini 3,923
3 Rohan Leuva 3,176
4 Maciej Los 2,633


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 26 Apr 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid