Cyberiafreak

"Fortunate are those who take the first steps.” ― Paulo Coelho

jQuery to my project !!

Currently i’m involved in designing a complete web application all alone and learning a lot these days. Doing a lot of POC and observing the best available things to the current Project. In this, jQuery is my latest crush,i knew JQuery for the past one year after Scott announcement but i never had a change to work for client project. Here is my first POC for no bie’s.. jQuery is a fast, lightweight JS
library that is CSS3 compliant and supports many browsers. The jQuery
framework is extensible and very nicely handles DOM manipulations, CSS,
AJAX, Events and Animations. Complete list of download available here.JQuery is not a JS replacement, but its a l
ibrary written using JavaScript.
1) Download from here
2) Add as reference.


 In aspx file.. 

$(document).ready(function() {
    // Add the page method call as an onclick handler for the div.
    $("#buttonn").click(function() {
        $.ajax({
            type: "POST",
            url: "MyJQuery.aspx/Samplemethod",
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                $("#Mydiv").text(msg.d);
            }
        });
    });
});

<body>
    <form id="form1" runat="server">
    <div id="Mydiv">
    </div>
    <input id="Text1" type="text" />
    <input id="buttonn" type="button" value="button" />
    </form>
</body>
</html>
 In Code behind..
[System.Web.Services.WebMethod]
        public static string Samplemethod()
        {
            return DateTime.Now.ToString();
        }
You could see, the page gets the latest date and time easily…

Advertisements

March 2, 2009 - Posted by | ASP.NET >>

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: