Simple Ajax with .NET
Adding Ajax to an application is simple and easy! Ajax is a powerful tool and can make your application look and feel great!
First let’s start by adding a “Script Manager” to the page, now we only have to add this once so it’s best placed in your Master page. The Script Manager needs to be placed between the form tags on your page like so:
1 2 3 4 | <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </form> |
After that, we can now add Ajax to an item. Below I have added an “Update Panel” to a list view. Now every action that list view makes will be way of HTTP Requests “Ajax”!
1 2 3 4 5 6 7 8 | <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListView ID="ListView1" runat="server" DataKeyNames="PostID" DataSourceID="ObjectDataSource1"> ' Your code here... </asp:ListView> </ContentTemplate> </asp:UpdatePanel> |
Winn .NET Guestbook
I am in the process of building a sweet little open source Guestbook in VB.NET 3.5. This guestbook will be dramatically updated from the original Winn ASP Guestbook. At that time I will drop all support for the ASP guestbook and remove it from my server. The ASP guestbook has had a good run and has been downloaded 11,281 times! I hope that the new .NET version will have great success in its place.
What will you need to host the new guestbook? For starters you will need .NET 3.5, then you may load the database file in Access or SQL 2005 or newer. Watch the project tab for more info.
Web User Controls
Using the user controls may be one of the best moves you will make when developing an application in .NET. The user control will allow you to separate your reusable logic and keep it in one place. For many developers this is a great thing! Many of us have to re-create items over and over, after some time your code can look like crap and then you feel like crap because you have to deal with it.
Let’s say we have a site where I needed a “Quick Search” on every other page, but each page had a different look and feel or a different CSS document. All I would need to do is create a web user control “.ascx” file and lay down the basics of my quick search. Assign the div’s ID’s or classes, then include your control in each page that needs it. To style, just use your style sheet assigned to that page an add your styles.
Web controls make life a little easier when developing in .NET, so be sure to take advantage of this great tool and stop duplicating your work!
Functions in VB
Something that i picked up on was that functions in VB and functions in PHP are a lot alike! This is great news, VB does not have the huge learning curve when stepping in from PHP.
Below i have created a simple function inside if a class:
Public Class Core
Public Function HelloWorld(AVar)
Return "Hello " & AVar
End Function
End Class
Remember, in VB that if you have a function it will need to return a value but a Sub cant return one.
Calling constants in VB
So i found my self needing to call on constants from another vb file. The file name was “core.vb”, now i needed to call a public constant and a public function. To do so, you can just first call the project name then call the file name and lastly call the constant or function.
// for a constant
<%=MyProject.core.MyConst %>
// for a function
<%=MyProject.core.MyFunction() %>
There is no need to “include” the vb file, .NET will know what you need and get it.
.NET Winn Guestbook v1.0
Say welcome to the Winn Guestbook in .NET 3.5 VB. I have released version 1.0, this is a bare bones release with nothing but the basics. This is a nice upgrade if your running the old Winn ASP Guestbook in ASP Classic. You will need to make sure your server is running .NET 3.5 and supports SQL Express or has an SQL server.
I dont plan on writing a porting script that would transition all your posts from the old ASP Classic version to the new .NET version, this will need to be done by hand.
Categories
Pages
- contact
- Contact Form V1.8
- FlickrHelper
- Guestbook V1.01 ASP
- Guestbook V2.4.7
- iFrame Loader
- Scriptatype:PHP
- Winn Cal
- Winn Tracker
