1

I have the following model which is wrapped in my view model i want to pass MaximumDaysAheadBookable property to datepicker function

public class SessionObject { public int MaximumNumberOfRooms { get; set; } public int MaximumNumberOfAdultsPerRoom { get; set; } public int MaximumNumberOfChildrenPerRoom { get; set; } public int MaximumDaysAheadBookable { get; set; } public int MaximumDaysBetweenCheckinCheckout { get; set; } } 

How do I access one of the above properties from Javascript.js file ? then pass it to datepicker function :

$('document').ready(function () { $("#Arrival").datepicker({ minDate: 0, maxDate:MaximumDaysAheadBookable , ////here i want to pass model value dateFormat: 'dd/mm/yy', showOn: "button", buttonImage: "img/ui_cal_icon.gif", buttonImageOnly: true, buttonText: "Select date", }); });

3
  • 1
    Server side (razor) code is not parsed in external files. You need to declare it in the main view (e.g. var maxDate = @Model.MaximumDaysAheadBookable; and then in the external file - maxDate: maxDate, Commented May 10, 2017 at 9:16
  • There has to be a duplicate Commented May 10, 2017 at 9:17
  • @StephenMuecke this is what i want correctly , thanks Commented May 10, 2017 at 11:12

1 Answer 1

0

In a external js file you will need to pass the data as a parameter.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.