Web Developer Blog from Microsoft.NET, C#, Visual Basic, JSP, Python, Ruby, PHP

Beginning Ajax and ASP.NET 3.5

by Dotnetindex Published 8/11/2008 | ASP.NET |
 Vote this news:

Ajax is a great helper to us while developing rapid applications without worrying us at power of asynchronous. In Visyal Web Developer 2008 comes with builtin Atlas and ASP.NET3.5 . In this tutorial, I try to show you what's ajax and database querying at same time.

Now let's build our scene. Open an empty web site and dop a ScriptManager and UpdatePanel from Ajax Extensions tab. Close the tab and open standard controls and drop one textbox and one button. Place a label inside ajax control and one more outside of UpDatePanel. The second label will display that we are using Ajax and page is not posting back. I will add some hard codes and I have put s SqlDataSource and a GridView. Complete code is below.

Ajax Atlas ASP.NET 35

What's going on!

I'm sure that, you're thinking that that was too easy. We have just write a scene for Visual Web Developer and place all actors on board. When we start application, first label (outside of Ajax Control) will display the second of request time. Type a character on textbox and hit the burtton. Ajax will fill the GridView without posting page and label2 will display working second of application. Look at that label1 did not change. Because page loaded only one time but Ajax loaded data intop GridView without posting request. Only a small part of page has been updated.

Here is the page code:



 

ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock] FROM [Alphabetical list of products] WHERE ([ProductName] LIKE '%' + @ProductName + '%')">
PropertyName="Text" Type="String" />

DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
InsertVisible="False" ReadOnly="True" SortExpression="ProductID" />
SortExpression="ProductName" />
SortExpression="UnitPrice" />
SortExpression="UnitsInStock" />

Code Behind file:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Label2.Text = Date.Now.Second
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = Date.Now.Second
End Sub

In code behind, we have passed page load time in second. Butwhen we hit the button ajax will change runtime to label which is label2 is a member control in our Ajax code.

In this tutorial, I try to build a very very simple application which fills the a data grid with our textbox control. Notice that, data grid will be filled after hitting the button that needs an action after page loaded.

Happy Coding!

 

Comments:
Only members can write comments.Please, login / register to write comment.

Best HTML5 Books

Here is the list of top HTML5: HTML5 For Web Designers ,  Introducing HTML5, Pro HTML5 Programming, Dive Into HTML5. Examples, frameworks, source codes and sample chapters can found at from original websites and directly download as e-book or order online


Getting the primary key value of the record

Often, we need to insert a new record in a table with an autonumber variable as primary key, and get the value of the automatically generated primary key back. For instance, when we start a new session for a user, and we need the sessionID to insert as a foreign key into an order table or so. 


Simple PHP SOAP example

This post will show a simple example of how to interpretate a WSDL file and a very simple, yet quick example of how to extract information from this file through PHP.

In this example I assume that you've already have SOAP enabled in your PHP configuration because this is beyond the scope of this example. If you're not sure, you can check your phpinfo file.


Using an alternate JSON Serializer in ASP.NET Web API

The new ASP.NET Web API that Microsoft released alongside MVC 4.0 Beta last week is a great framework for building REST and AJAX APIs. I've been working with it for quite a while now and I really like the way it works and the complete set of features it provides 'in the box'. It's about time that Microsoft gets a decent API for building generic HTTP endpoints into the framework.


How to Convert a PSD to XHTML

I continue to be amazed by how well Collis’s “Build a Sleek Portfolio Site From Scratch” tutorial continues to perform. It’s been months, yet it still posts strong numbers every week. Considering that fact, I decided to create a screencast that shows you exactly how to convert a PSD into perfect XHTML/CSS. (Read More)

Source Code








Search

Member login

Who's online

  • There 15 online users.