Click here to Skip to main content
15,885,880 members
Articles / Web Development / HTML

ASP.NET MVC Application in Action - I (DailyJournal)

Rate me:
Please Sign up or sign in to vote.
4.84/5 (17 votes)
7 Jun 2010CPOL5 min read 65.5K   1.3K   64  
A simple visual task manager application using ASP.NET MVC and jQuery.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<DailyJournal.Models.TaskStatus>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	AddTaskStatus
</asp:Content>

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

   <form method="post" id="frm-task-status" name="frm-task-status">
        <%= Html.ValidationSummary(true) %>

        <fieldset>
            <legend>Fields</legend>
            
            <div class="editor-label">
                <%= Html.Label("Work Area") %>
            </div>
            <div class="editor-label">
                <%= Html.DropDownListFor(model => model.WorkAreaId, ViewData["WORK_AREA"] as SelectList) %>
            </div>
            
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Type) %>
            </div>
            
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Type) %>
                <%= Html.ValidationMessageFor(model => model.Type) %>
            </div>
            
            <div class="editor-label">
                <%= Html.LabelFor(model => model.Description) %>
            </div>
            <div class="editor-field">
                <%= Html.TextBoxFor(model => model.Description) %>
                <%= Html.ValidationMessageFor(model => model.Description) %>
            </div>
            
            <p>
                <input type="button" id="btnSaveTaskStatus" value="Save" />
            </p>
        </fieldset>

    </form>


    <%= Html.ActionLink("Back to Dashboard", "Index", "Dashboard") %>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">


<script type="text/javascript">
    $(function() {
        $("#btnSaveTaskStatus").click(function() {
            SaveTaskStatus();
        });
    });

    function SaveTaskStatus() {
        var postedData = $("#frm-task-status").serialize();

        $.ajax({
            type: "POST",
            url: "/work/savetaskstatus",
            data: postedData,
            beforeSend: function(XMLHttpRequest) {
                $('#loading-panel').dialog('open');
            },
            success: function(response) {
                ClearForm();
            },
            error: function(msg) {
                alert(msg);
            },
            complete: function(XMLHttpRequest, textStatus) {
                $("#loading-panel").dialog('close');

            }
        });
    }

    function ClearForm() {
        $("#Type").val("");
        $("#Description").val("");
        
    }
</script>

</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder Algorisys Technologies Pvt. Ltd.
India India
Co Founder at Algorisys Technologies Pvt. Ltd.

http://algorisys.com/
https://teachyourselfcoding.com/ (free early access)
https://www.youtube.com/user/tekacademylabs/

Comments and Discussions