Preferred Language:
Listing 33.19 - EditMovies.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Edit Movies</title>
<script type="text/javascript">
function pageLoad()
{
$addHandler($get("btnAdd"), "click", addMovie);
bindMovies();
}
function bindMovies()
{
MovieService.SelectAll(selectAllSuccess);
}
function addMovie()
{
var movieToAdd =
{
Title: $get("txtTitle").value,
Director: $get("txtDirector").value
};
MovieService.Insert(movieToAdd, addMovieSuccess);
}
function addMovieSuccess()
{
bindMovies();
}
function selectAllSuccess(results)
{
var sb = new Sys.StringBuilder()
var movie;
var row;
for (var i=0;i < results.length; i++)
{
movie = results[i];
row = String.format("{0} directed by {1}<br />", movie.Title, movie.Director);
sb.appendLine(row);
}
$get("divMovies").innerHTML = sb.toString();
}
</script>
</head>
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference InlineScript="true" Path="~/Services/MovieService.asmx" />
</Services>
</asp:ScriptManager>
<fieldset>
<legend>Add Movie</legend>
<label for="txtTitle">Title:</label>
<input id="txtTitle" />
<br /><br />
<label for="txtTitle">Director:</label>
<input id="txtDirector" />
<br /><br />
<input id="btnAdd" type="button" value="Add Movie" />
</fieldset>
<div id="divMovies"></div>
</form>
</body>
</html>
Need ASP.NET and Visual Studio 2008 Training?
- Learn ASP.NET 3.5 from Stephen Walther, author of ASP.NET 3.5 Unleashed.
We've provided ASP.NET training for NASA, Lockheed Martin, the National Science Foundation, Verizon,
Boeing, the US House of Representatives, Kaiser, Petco, Mary Kay, and Microsoft.
Why not your company?
-
Receive a four day, hands-on, intensive workshop.
-
We fly to you, anywhere in the world.
-
We can bring our own laptops.
To learn more, visit the
Superexpert Training website.