Posts tagged "jQuery"

Easy way to Implement Ajax using Jquery in Asp.net


A simple steps to perform some action which asynchronous to the server using Jquery and Asp.Net.Here I am using Visual Studio 2008,Jquery and C# to perform this.Here I am just giving the code for doing that.I am just mentioning the way to take the data to a server page without using Handlers.This can be useful for person who have some knowledge about asp.net and its working and beginners in jquery


Thanks to Jquery for doing wonderful operations with minimum code . Obviously the server controls in the asp.net which are always supports for post-back operations.I am here mentioning some code which is suitable for insertion of data from an aspx page.It can be from pop-up or simple aspx.


Please follow these steps to  perform my code.I hope you know how to create an aspx site using visual studio.


Step 1. Create a website project and hope you will be having a Default.aspx page.


Step 2. Place some controls in the form.Make ensure that we are using Html controls instead of asp.net server controls.If we are using server controls it is difficult to serialize the controls when it passed to aspx page.So we are using html controls with server tag.


Here i am using two text boxes which is by type input but they will be having unique Id and it will be runs at server.So it will be similar to asp controls.We cannot have the asp events with them.In the “default.aspx” it is possible to access using ” txtName.ClientID” etc.


Step 3.you need to add jquery source file to get the functions which is mentioned that release. Please click here to get the release(jquery-1.4.2.min.js).Please visit www.jquery.com for downloading the file.


Step 4. Make sure that you given the source path of your javascript correctly.



Step 5.Now to perform the operation using Jquery.Please make sure that use must use the document ready function of Jquery. 

$(document).ready(function(){// code });Step 6. Perform the JavaScript coding

function saveData(){ $.ajax({ type: ‘POST’, url: getUrl(‘test’), data: { name: $(‘#frmAdd’).serialize() }, cache: false, error: function(xhr, status, errorThrown) { alert(errorThrown + ‘\n’ + status + ‘\n’ + xhr.statusText); }, success: function(html) { if (html.toString().indexOf(“successfully”) > 0) { alert(html); } else { alert(html); } }, dataType: ‘html’ }); }

Here we are using the $.ajax method for doing the ajax operation.I am not mentioning about the function.Please check the www.jquery.com for more information about the function.We are using here the “POST” method to send data to server.The url will be url of the aspx page.We can also call a function here or direct give the url.It is possible to pass the query string along with the url here.Here we are serializing the entire form and the controls using the jquery serialize method.The error part will perform the function when there will be error occurred from the server.The sucess function will perform when the server operation or a reply is occured.the html here will returns the response from the server.Since we are using text/html as response we give the datatype as html.


Step 7.Add a html button to the form and then on call saveData() on its “onClick”


Step 8.Now its turn to do some server side codings in C#.So go to Default.aspx.cs

if (Request.Params["name"] != null) { prms = Request.Params["name"].ToString(); App_Utilities.JQDeSeriazile controls = new Jquery_Asp.Net.App_Utilities.JQDeSeriazile(Request.Params["name"]); string name = controls[txtName.UniqueID].Value; string age = controls[txtAge.UniqueID].Value; string strMsg = “Employees successfully Allocateded”; Response.Flush(); Response.Expires = -1; Response.Write(strMsg); Debug.Write(strMsg); Response.End(); }  

Step 9. The class JQDeSerialize is a user defined class which is used to deserialize the jquery serialized data


Use the “var” button to to wrap Variable or class names in <code> tags like this.


Did you learn anything interesting/fun/annoying while writing the code? Did you do anything particularl clever or wild or zany?  


Keep a running update of any changes or improvements you’ve made here.   


View the original article here



Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - August 27, 2010 at 5:20 am

Categories: C#   Tags: ASP.NET, Implement, jQuery, Using

Using jQuery to Open External Links in a New Window – Expression Web

Learning jQuery has been on my to-do list from quite some time and finally, I am getting some hands-on with it. Suprotim’s eBook ’51 Recipes using jQuery and ASP.NET Controls’ has been very helpful and I am learning how to apply these tricks on my HTML web pages created using Expression Web.

If you are new to jQuery, check this article ‘How jQuery Works’jQuery is a fast, lightweight JavaScript 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.

While I continue my exploration with jQuery, I would like to share whatever I have learnt about jQuery with my readers. This article is about using jQuery to open external links (links that point to a domain other than yours) in a new window.I usually like to open up a link on a website in a new tab or a new window.

This makes it easier for me to remember where I was and I always have the original page opened with me. There are some sites which contain links that open in the same window, and one link leads to another and I keep browsing pages in the same window.

At some point, I realize I need to go back to the original page I visited and I don’t remember the URL. So I need to hit the back button on the browser several times, until I reach that page.

Now if you are building your website in Expression Web, you can open links in a new window using the ‘Hyperlink Properties’. Select the hyperlink, right click and choose Hyperlink Properties from the menu.

In the Edit hyperlink window, choose ‘Target Frame’. In the Target Frame window, select New Window from the list.

View the Original article

Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - May 17, 2010 at 1:14 am

Categories: ASP.NET   Tags: Expression, External, jQuery, Links, Using, window

ASP.NET Page Curls using jQuery

Have you seen pages with a curl in the corner, which on a mouse over, curls further to reveal an image or a page element kept under it? They are also called as ‘Dog Ears’ or ‘Page Peels’.Although creating them looks like a tedious job, plug-ins like the Sexy Curls jQuery Plugin makes it very simple to add Page Curls to your web pages.

In this short article, I will show you how to use this jQuery plug-in to add curls to your existing ASP.NET pages.

The same concept can also be applied to an HTML page. As the author Elliott Kember states in his blog, along with the jQuery Library, this plug-in also requires the jQuery UI Resizable module.

I am using the jQuery and jQuery UI scripts hosted on Google CDN. However you can always customize your jQuery UI download by selecting only the resizable module from here. Here’s a screenshot of how the curls look like on a page.

View the Original article

Be the first to comment - What do you think?
Posted by Anand Narayanaswamy - May 16, 2010 at 2:49 am

Categories: ASP.NET   Tags: ASP.NET, briefly about c# and c# tools, c sharp compiler download, c# compilers, C# keywords classified, Curls, develop in c# in windows98, download C# compiler for windows xp, download different Types Of Compilers in C#, explain briefly about c# and c# tools, jQuery, multiform application in C#.Net, Using

Microsoft, jQuery, and Templating

About two months ago, John Resig and I met at Café Algiers in Harvard square to discuss how Microsoft can contribute to the jQuery project. Today, Scott Guthrie announced in his second-day MIX keynote that Microsoft is throwing its weight behind jQuery and making it the primary way to develop client-side Ajax applications using Microsoft technologies.

What does this announcement mean?

It means that Microsoft is shifting its resources to invest in jQuery. Developers on the ASP.NET team are now working full-time to contribute features to the core jQuery library. Furthermore, we are working with other teams at Microsoft to ensure that our technologies work great with jQuery.

We are contributing to the open-source jQuery project in the exact same way that any other company or individual from the community can contribute to jQuery. We are writing proposals, submitting the proposals to the jQuery forums, and revising the proposals in response to community feedback. The jQuery team can decide to reject or accept any feature that we propose.

Any feature that Microsoft contributes to jQuery will be platform neutral. In other words, Microsoft contributions will benefit PHP and RAILS developers just as much as they benefit ASP.NET developers. Microsoft contributions to jQuery will improve the web for everyone.

Contributing Support for Templates to jQuery Core

Our first proposal concerns templating. We want to contribute support for templates to jQuery so that JavaScript developers can use jQuery to easily display a set of database records. You can read our templating proposal here:

http://wiki.github.com/nje/jquery/jquery-templates-proposal

You can download and play with our prototype for templating here:

http://github.com/nje/jquery-tmpl

The following code illustrates how you can use a template to display a set of products in a bulleted list: