Click here to Skip to main content
12,248,742 members (43,591 online)

.NET Framework

 
AnswerRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 6:04
protectorPete O'Hanlon10-Dec-12 6:04 
GeneralRe: Deploying a Windows Service Pin
indian14310-Dec-12 6:08
memberindian14310-Dec-12 6:08 
GeneralRe: Deploying a Windows Service Pin
Pete O'Hanlon10-Dec-12 6:20
protectorPete O'Hanlon10-Dec-12 6:20 
Questionrun through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 3:04
memberxnaLearner10-Dec-12 3:04 
AnswerRe: run through startDate to endDate and add each record to DB Pin
xnaLearner10-Dec-12 3:35
memberxnaLearner10-Dec-12 3:35 
QuestionASP.NET Post Textbox After Button Click Pin
xnaLearner9-Dec-12 12:15
memberxnaLearner9-Dec-12 12:15 
AnswerRe: ASP.NET Post Textbox After Button Click Pin
Richard MacCutchan9-Dec-12 22:54
mvpRichard MacCutchan9-Dec-12 22:54 
GeneralRe: ASP.NET Post Textbox After Button Click Pin
xnaLearner10-Dec-12 1:14
memberxnaLearner10-Dec-12 1:14 
Question.netframework Pin
zofi518-Dec-12 5:30
memberzofi518-Dec-12 5:30 
AnswerRe: .netframework Pin
Dave Kreskowiak8-Dec-12 7:37
mvpDave Kreskowiak8-Dec-12 7:37 
AnswerRe: .netframework Pin
Eddy Vluggen8-Dec-12 8:18
memberEddy Vluggen8-Dec-12 8:18 
GeneralRe: .netframework Pin
Kevin Bewley14-Jan-13 0:46
memberKevin Bewley14-Jan-13 0:46 
AnswerRe: .netframework Pin
jibesh11-Dec-12 11:36
memberjibesh11-Dec-12 11:36 
QuestionEnter 3 dates and display order in different VIEW, after click Pin
xnaLearner7-Dec-12 10:52
memberxnaLearner7-Dec-12 10:52 
Hey guys so im attempting to throw a project together to increase my knowledge of MVC3 but I have hit a wall...

So from my HolidaysController inside my index 'view' I have created a hyperlink which will navigate the user to the 'create3' ActionResult

@Html.ActionLink("Select 3 Dates", "Create3")
-------------------
In my create3 page I want the user to enter 3 dates into text boxes and when they click 'create' the user will be returned to the previous HolidaysController/Index page
where the dates will be displayed in order of ascending date....ATM I have this working up until the user enters 3 dates and clicks 'create'...However I only know
how to display a message box displaying the order, it is working I just need help getting the order to be displayed from the index page.

Please see my code:
Code for HolidayController/Index:
--------------
//submit will go to post
   [HttpPost]
   public ViewResult Index(int HolidayDate)
   {
       var holidays = db.Holidays.Include("Person");
 
       HolidayList model = new HolidayList();
 
       model.currentPersonID = HolidayDate;
       model.PList4DD = db.People.ToList();
       model.Categories = holidays.Select(x => new SelectListItem
                                       {
                                           Value = x.Id.ToString(),
                                           Text = x.Person.Name
                                       }
                                     );
 

       int data = HolidayDate;
 
       model.HList4DD = db.Holidays.Where(h => h.PersonId == HolidayDate).ToList();
 
       return View(model);
 
   }
 
   [HttpGet]
   public ViewResult Index(string sortOrder, int? currentPersonID)
   {
       var holidays = db.Holidays.Include("Person");
 
       HolidayList model = new HolidayList();
 
       //not null
       if (currentPersonID.HasValue)
       {
           model.currentPersonID = currentPersonID.Value;
 
       }
       else
       {
           model.currentPersonID = 0;
       }
 
       model.PList4DD = db.People.ToList();
 
       ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "date" : "";
       var dates = from d in db.Holidays
                   where d.PersonId == currentPersonID.Value
                   select d;
 
       switch (sortOrder)
       {
           case "date":
               dates = dates.OrderBy(p => p.HolidayDate);
               break;
       }
 
       model.HList4DD = dates.ToList();
 
       return View(model);
   }
-----------------------
//View for Index
 
@*@model IEnumerable<HolidayBookingApp.Models.Holiday>*@
@model HolidayBookingApp.Models.HolidayList
@{
    ViewBag.Title = "Index";
}
 
<h2>Index</h2>
 
<p>
    @Html.ActionLink("Create New", "Create")
</p>
 
<p>
@Html.ActionLink("Select 3 Dates", "Create3")
</p>
 
<table>
    <tr>
        <th>
            PersonId
        </th>
        <th>
            @*HolidayDate*@
            @Html.ActionLink("HolidayDate", "Index", new { sortOrder = ViewBag.NameSortParm, currentPersonID = Model.currentPersonID })
        </th>
        <th></th>
    </tr>
    <tr>  
    </tr>
 
@foreach (var item in Model.HList4DD)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.PersonId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.HolidayDate)
           
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
            @Html.ActionLink("Details", "Details", new { id = item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.Id })
        </td>
    </tr>}
    
    <tr>
      <div class="editor-label">
         @*   @Html.LabelFor(model => model.PList4DD, "Person")*@
        </div>
 
        <div class="editor-field">           
             <form action ="/Holidays/Index" id="some" method="post"> 
 
  @Html.DropDownListFor(model => model.HList4DD.First().HolidayDate, new SelectList(Model.PList4DD, "Id", "Name", Model.currentPersonID), "--select--")    
       <script>
           function updateFormEnabled() 
           {
               if (verifyAdSettings()) 
               {
                   $('#sbmt').removeAttr('disabled');
               }
               else 
               {
                   $('#sbmt').attr('disabled', 'disabled');
               }
           }
 
           function verifyAdSettings() 
           {
               if ($('#HolidayDate').val() != '') 
               {
                   return true;
               }
               else 
               {
                   return false;
               }
           }
 
           $('#HolidayDate').change(updateFormEnabled);
      
           </script>
           
             <input type="submit" id= "sbmt" name="ViewHolidaysDD" value="View"/>
              </form>
  <script>
      $('#sbmt').attr('disabled', '');
        </script>
 
        </div>
 
</table>
 

 

 
<table>
    <div>
    Judging by your selection the order of dates are: //HERE IS WHERE I WANT TO DISPLAY THE ORDER OF DATES
    </div>
 
</table>


Just above is where I want to display my dates in order, ascending
------------
-----------------------------------
//my create 3 Action result

 
 [HttpGet]
        public ActionResult Create3()
        {
            return View();
        }
 
        [HttpPost]
        public ActionResult Create3(string date1, string date2, string date3)
        {
            string FirstDateOrder, SecondDateOrder, ThirdDateOrder;
         
            //date 1 is biggest
            if (date1.Length > date2.Length && date1.Length > date3.Length)
            {
                //date 2 is 2nd & date 3 is 3rd
                if (date2.Length > date3.Length)
                {
                    FirstDateOrder = date1;
                    SecondDateOrder = date2;
                    ThirdDateOrder = date3;
 
                    System.Windows.Forms.MessageBox.Show("Order is 1, 2, 3");
 
                    return RedirectToAction("Index");
                }
 
                //date 3 is 2nd & date 2 is 3rd
                else
                {
                    FirstDateOrder = date1;
                    SecondDateOrder = date3;
                    ThirdDateOrder = date2;
 
                    System.Windows.Forms.MessageBox.Show("Order is 1, 3, 2");
 
                    return RedirectToAction("Index");
                }
              
            }
 
            //date 2 is biggest
            if (date2.Length > date1.Length && date2.Length > date3.Length)
            {
                //date 1 is 2nd & date 3 is 3rd
                if (date1.Length > date3.Length)
                {
                    FirstDateOrder = date2;
                    SecondDateOrder = date1;
                    ThirdDateOrder = date3;
 
                    System.Windows.Forms.MessageBox.Show("Order is 2, 1, 3");
 
                    return RedirectToAction("Index");
                }
 
                //date 3 is 2nd & date 1 is 3rd
                else
                {
                    FirstDateOrder = date2;
                    SecondDateOrder = date3;
                    ThirdDateOrder = date1;
 
                    System.Windows.Forms.MessageBox.Show("Order is 2, 3, 1");
 
                    return RedirectToAction("Index");
                }
 
            }
 
            //date 3 is biggest
            if (date3.Length > date1.Length && date3.Length > date2.Length)
            {
                //date 1 is 2nd & date 2 is 3rd
                if (date1.Length > date2.Length)
                {
                    FirstDateOrder = date3;
                    SecondDateOrder = date1;
                    ThirdDateOrder = date2;
 
                    System.Windows.Forms.MessageBox.Show("Order is 3, 1, 2");
 
                    return RedirectToAction("Index");
                }
 
                //date 2 is 2nd & date 1 is 3rd
                else
                {
                    FirstDateOrder = date3;
                    SecondDateOrder = date2;
                    ThirdDateOrder = date1;
 
                    System.Windows.Forms.MessageBox.Show("Order is 3, 2, 1");
 
                    return RedirectToAction("Index");
                }
 
            }
 
            
            return RedirectToAction("Index");
        }
-----------------------------
--------------
and my view:
 
	@model HolidayBookingApp.Models.Dates
 
@{
    ViewBag.Title = "Create3";
}
 
<h2>Create3</h2>

---------------
Not sure where to go from here something like create a paramter in the Index View which pulls across the order?

Any help would be great thanks guys and sorry about the essay
Question[VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
steve_94966136-Dec-12 22:37
membersteve_94966136-Dec-12 22:37 
AnswerRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
Zaf Khan10-Dec-12 18:57
memberZaf Khan10-Dec-12 18:57 
GeneralRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
steve_949661311-Dec-12 22:20
membersteve_949661311-Dec-12 22:20 
GeneralRe: [VB.NET 2008] How to detect if a page of a TabControl is selected (Windows CE) Pin
Zaf Khan12-Dec-12 3:13
memberZaf Khan12-Dec-12 3:13 
Question[VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966135-Dec-12 5:54
membersteve_94966135-Dec-12 5:54 
AnswerRe: [VB.NET 2008] How to get control on objects created at runtime Pin
Eddy Vluggen5-Dec-12 6:40
memberEddy Vluggen5-Dec-12 6:40 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966135-Dec-12 21:59
membersteve_94966135-Dec-12 21:59 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
Eddy Vluggen6-Dec-12 3:27
memberEddy Vluggen6-Dec-12 3:27 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966136-Dec-12 4:26
membersteve_94966136-Dec-12 4:26 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
Eddy Vluggen6-Dec-12 6:02
memberEddy Vluggen6-Dec-12 6:02 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
steve_94966136-Dec-12 22:25
membersteve_94966136-Dec-12 22:25 
GeneralRe: [VB.NET 2008] How to get control on objects created at runtime Pin
Eddy Vluggen7-Dec-12 2:16
memberEddy Vluggen7-Dec-12 2:16 
QuestionTesting Practices Pin
Andrew Stoute5-Dec-12 5:44
memberAndrew Stoute5-Dec-12 5:44 
AnswerRe: Testing Practices Pin
Eddy Vluggen5-Dec-12 6:36
memberEddy Vluggen5-Dec-12 6:36 
GeneralRe: Testing Practices Pin
Andrew Stoute5-Dec-12 6:45
memberAndrew Stoute5-Dec-12 6:45 
GeneralRe: Testing Practices Pin
Eddy Vluggen5-Dec-12 6:53
memberEddy Vluggen5-Dec-12 6:53 
GeneralRe: Testing Practices Pin
Dave Kreskowiak5-Dec-12 7:29
mvpDave Kreskowiak5-Dec-12 7:29 
GeneralRe: Testing Practices Pin
Dave Kreskowiak5-Dec-12 7:26
mvpDave Kreskowiak5-Dec-12 7:26 
GeneralRe: Testing Practices Pin
Eddy Vluggen5-Dec-12 7:34
memberEddy Vluggen5-Dec-12 7:34 
GeneralRe: Testing Practices Pin
Dave Kreskowiak5-Dec-12 10:55
mvpDave Kreskowiak5-Dec-12 10:55 
GeneralRe: Testing Practices Pin
Eddy Vluggen6-Dec-12 1:08
memberEddy Vluggen6-Dec-12 1:08 
QuestionHow to make a list view and gallerie view on a product page list on some e-commerce Pin
El daniel4-Dec-12 1:19
memberEl daniel4-Dec-12 1:19 
AnswerRe: How to make a list view and gallerie view on a product page list on some e-commerce Pin
Eddy Vluggen4-Dec-12 1:37
memberEddy Vluggen4-Dec-12 1:37 
Questionframework 2.0 and win98 Pin
caradri3-Dec-12 23:37
membercaradri3-Dec-12 23:37 
AnswerRe: framework 2.0 and win98 Pin
Richard MacCutchan4-Dec-12 0:01
mvpRichard MacCutchan4-Dec-12 0:01 
AnswerRe: framework 2.0 and win98 Pin
Eddy Vluggen4-Dec-12 0:04
memberEddy Vluggen4-Dec-12 0:04 
AnswerRe: framework 2.0 and win98 Pin
Pete O'Hanlon4-Dec-12 0:07
protectorPete O'Hanlon4-Dec-12 0:07 
GeneralRe: framework 2.0 and win98 Pin
Eddy Vluggen4-Dec-12 0:31
memberEddy Vluggen4-Dec-12 0:31 
GeneralRe: framework 2.0 and win98 Pin
Pete O'Hanlon4-Dec-12 0:38
protectorPete O'Hanlon4-Dec-12 0:38 
GeneralRe: framework 2.0 and win98 Pin
Eddy Vluggen4-Dec-12 0:43
memberEddy Vluggen4-Dec-12 0:43 
GeneralRe: framework 2.0 and win98 Pin
Pete O'Hanlon4-Dec-12 0:41
protectorPete O'Hanlon4-Dec-12 0:41 
GeneralRe: framework 2.0 and win98 Pin
caradri4-Dec-12 1:25
membercaradri4-Dec-12 1:25 
GeneralRe: framework 2.0 and win98 Pin
Dave Kreskowiak4-Dec-12 5:11
mvpDave Kreskowiak4-Dec-12 5:11 
GeneralRe: framework 2.0 and win98 Pin
caradri4-Dec-12 1:23
membercaradri4-Dec-12 1:23 
GeneralRe: framework 2.0 and win98 Pin
Eddy Vluggen4-Dec-12 1:36
memberEddy Vluggen4-Dec-12 1:36 
GeneralRe: framework 2.0 and win98 Pin
caradri4-Dec-12 2:52
membercaradri4-Dec-12 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 28 Apr 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid