View Single Post
  #5 (permalink)  
Old December 17th, 2010, 04:15 PM
lagonave lagonave is offline
Registered User
 
Join Date: Dec 2010
Posts: 8
Thanks: 6
Thanked 2 Times in 2 Posts
Default Calling the "Register" method using AJAX

flyinhawaiian,

I just saw that the code that you have posted is the next step on that tutorial on page 124. I'm still trying to get page 122-123 to work according to the book. Something is missing and I can't put my hands on it yet.

Here is my complete code for the "Detail.aspx":

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NerdDinner.Model s.Dinner>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.js" type="text/javascript"></script>
Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<h2><%: Model.Title %></h2>
<p>
<strong>When:</strong>
<%: Model.EventDate.ToShortDateString() %>
<strong>@</strong>
<%: Model.EventDate.ToShortTimeString() %>
</p>
<p>
<strong>Where:</strong>
<%: Model.Address %>,
<%: Model.Country %>
</p>
<p>
<strong>Description:</strong>
<%: Model.Description %>
</p>
<p>
<strong>Organizer:</strong>
<%: Model.HostedBy %> (<%: Model.ContactPhone %>)
</p>

<div id="rsvpmsg">
<% if(Request.IsAuthenticated){ %>

<% if(Model.IsUserRegistered(Context.User.Identity.Na me)) { %>
<p>You are registered for this event!</p>

<% } else { %>

<%:Ajax.ActionLink("RSVP for this event (SecondTest)", "Register","RSVP", new { id=Model.DinnerID }, new AjaxOptions { UpdateTargetId="rsvpmsg"}) %>

<% } %>

<%} else { %>
<%: Html.ActionLink("Logon to RSVP for this event.", "LogOn", "Account") %>
<% } %>
</div>

<% if (Model.IsHostedBy(Context.User.Identity.Name)) { %>
<%: Html.ActionLink("Edit Dinner", "Edit", new { id = Model.DinnerID })%> |
<%: Html.ActionLink("Delete Dinner", "Delete", new { id = Model.DinnerID })%>
<%} %>

</asp:Content>
The Following User Says Thank You to lagonave For This Useful Post:
saymamohib26 (April 7th, 2011)