Click here to Skip to main content
       

.NET Framework

 
GeneralRe: problem with relationships PinmemberxnaLearner13-Dec-12 5:37 
Question[VB.NET 2008] DataSet and XML files Pinmembersteve_949661313-Dec-12 1:06 
AnswerRe: [VB.NET 2008] DataSet and XML files PinmemberEddy Vluggen13-Dec-12 5:28 
GeneralRe: [VB.NET 2008] DataSet and XML files Pinmembersteve_949661313-Dec-12 22:21 
GeneralRe: [VB.NET 2008] DataSet and XML files PinmemberEddy Vluggen14-Dec-12 1:34 
QuestionAssembly with different .NET framework versions Pinmembermarca29212-Dec-12 11:05 
AnswerRe: Assembly with different .NET framework versions PinmemberGerry Schmitz12-Dec-12 13:25 
QuestionUse A Cookie To Send PersonID To Different Page PinmemberxnaLearner12-Dec-12 5:33 
Hey guys so atm when the user goes to the holiday page, they can do 1 of 2 things
 
1)use a drop down box to select 'person name' and click 'view' this will display all the current holidays for this person
 
2)click 'create new' which will bring the user to a create page which allows them to add a new holiday(from here they select person name from drop and and select what date from calender)
 
This all works, however if the user originally follows the first path of selecting a person name and clicking view(it will display their holidays) if they then take the path of 2 and click 'create' it will jump to the create page. however the drop down box will be back at 'select' i would like the existing person selected from the previous drop down to display in this drop down.
 
A cookie or url/parameter?
 
anyway Im stuck please help
 
I've tried a cookie.
[code]
[HttpGet]
        public ViewResult Index(string sortOrder, int? currentPersonID)
        {
            var holidays = db.Holidays.Include("Person");
            HolidayList model = new HolidayList();
 
            if (currentPersonID.HasValue)
            {
                model.currentPersonID = currentPersonID.Value;
 
            }
            else
            {
                model.currentPersonID = 0;
            }
 
            model.PList4DD = db.People.ToList();
 
            //hyperlink to sort dates in ascending order
            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();
 
            var cookie = new HttpCookie("cookie_name", "currentPersonID");
            Response.AppendCookie(cookie);     
 
            return View(model);
        }
 
    public ActionResult Create()
        {
            var cookie = Request.Cookies["cookie_name"];
            if (cookie != null)
            {
                string value = cookie.Value;
                //int? value = cookie.Value;
            }
 
            ViewBag.cookie = cookie.Value;
 
            ViewBag.Id = new SelectList(db.People, "Id", "Name");
            return View();
 
//tried to use the currentPersonID in index as an int but it woudlnt allow me.
 
[/code]
My View
[code]
@model HolidayBookingApp.Models.startANDend
 

@{
    ViewBag.Title = "Create";
}
 
<p>
 

  <span>@ViewBag.cookie</span>
 

<h2>Create</h2>
 
<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
      @Html.ValidationSummary(true)
    <fieldset>
        <legend>Holiday</legend>
 
        <div>
            @Html.LabelFor(model => model.PersonId, "Person")
        </div>
 
        <div>     
            @Html.DropDownListFor(model => model.PersonId,
                                new SelectList(ViewBag.Id, "Value", "Text"),
                                "---Select---"
                                )   
         @Html.ValidationMessageFor(model => model.PersonId)            
        </div>
 
        <div>
            @Html.LabelFor(model => model.HolidayDate)
        </div>
 
        <div>
 
            @Html.TextBoxFor(model => model.HolidayDate)
 
            @Html.TextBoxFor(model => model.endDate)
    <script>
 
//        Date.format = 'dd/m/yyy';
        $("#HolidayDate").addClass('date-pick');
        $("#endDate").addClass('date-pick');
            //$('.date-pick').datePicker//({dateFormat: 'dd-mm-yy'}).val();

//        clickInput: true
 
        $(function () {
            //3 methods below dont allow user to select weekends
            $('.date-pick').datePicker(
               {
                   createButton: false,
                   renderCallback: function ($td, thisDate, month, year) {
                       if (thisDate.isWeekend()) {
                           $td.addClass('weekend');
                           $td.addClass('disabled');
                       }
 
                   }
               }
        )
 
        .bind('click',
            function () {
                $(this).dpDisplay();
                this.blur();
                return false;
            }
        )
 
        .bind('dateSelected',
            function (e, selectedDate, $td) {
                console.log('You selected ' + selectedDate);
            }
        );
 
            //        HolidayDate is start date
            $('#HolidayDate').bind('dpClosed',
                    function (e, selectedDates) {
                        var d = selectedDates[0];
                        if (d) {
                            d = new Date(d);
                            $('#endDate').dpSetStartDate(d.addDays(0).asString());
                        }
                    }
            );
 
            //end date is end date
            $('#endDate').bind('dpClosed',
                    function (e, selectedDates) {
                        var d = selectedDates[0];
                        if (d) {
                            d = new Date(d);
                            $('#HolidayDate').dpSetEndDate(d.addDays(0).asString());
                        }
                    }
                );
        });
 

 
    </script>
 
     @Html.ValidationMessageFor(model => model.HolidayDate)
        </div>
 
        <p>
            <input type="submit" value="Create"/>
        </p>
 

 
    </fieldset>
}
 
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
 
@*
<p>Current Person Selected is:
 
@TempData["currentPersonID"]
 
</p>*@
[code]
Once I get this going how can i get my drop down to store the value? Any help?
 
Thanks

Questiondont allow user to select existing date PinmemberxnaLearner10-Dec-12 6:46 
AnswerRe: dont allow user to select existing date PinprotectorPete O'Hanlon10-Dec-12 6:53 
GeneralRe: dont allow user to select existing date PinmemberxnaLearner10-Dec-12 7:23 
GeneralRe: dont allow user to select existing date PinmemberxnaLearner11-Dec-12 0:26 
GeneralRe: dont allow user to select existing date PinprotectorPete O'Hanlon11-Dec-12 0:32 
GeneralRe: dont allow user to select existing date PinmemberxnaLearner11-Dec-12 0:46 
GeneralRe: dont allow user to select existing date PinprotectorPete O'Hanlon11-Dec-12 0:51 
GeneralRe: dont allow user to select existing date PinmemberxnaLearner11-Dec-12 1:21 
GeneralRe: dont allow user to select existing date PinprotectorPete O'Hanlon11-Dec-12 2:02 
QuestionRun through loop for week and dont select weekends PinmemberxnaLearner10-Dec-12 5:13 
AnswerRe: Run through loop for week and dont select weekends PinprotectorPete O'Hanlon10-Dec-12 5:31 
GeneralRe: Run through loop for week and dont select weekends PinmemberxnaLearner10-Dec-12 5:52 
GeneralRe: Run through loop for week and dont select weekends PinprotectorPete O'Hanlon10-Dec-12 5:53 
QuestionDeploying a Windows Service Pinmemberindian14310-Dec-12 5:09 
AnswerRe: Deploying a Windows Service PinprotectorPete O'Hanlon10-Dec-12 6:04 
GeneralRe: Deploying a Windows Service Pinmemberindian14310-Dec-12 6:08 
GeneralRe: Deploying a Windows Service PinprotectorPete O'Hanlon10-Dec-12 6:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.141223.1 | Last Updated 25 Dec 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid