This is a migrated thread and some comments may be shown as answers.
How to create the default Action (like OnBeforeShow, OnBeforeShowDay) values in contructor
1 Answer 24 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rommel Manalo
Top achievements
Rank 1
Rommel Manalo asked on 23 Sep 2009, 10:33 AM
Setting the default values for the controls property is instantiate in the constructor just like below
 public DatePicker(...) : base(...)
        {
            ConstrainInput = true;
            NumberOfMonthsToShow = DefaultNumberOfMonthsToShow;
            MonthSteps = DefaultMonthSteps;
        }
The ConstrainInput, NumberOfMonthsToShow, MonthSteps of jQuery Calendars are set to its default values  but what if i want to create a default values for Action (like OnBeforeShow, OnBeforeShowDay, etc) how can I do that.  Let say a JavaScript something like this will be rendered inside this action
function(error, timestamp)
{
jQuery("#errorHolder").html("You cannot do this to me!");
}


1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 26 Sep 2009, 03:09 PM
Hello Rommel,

In order to achieve your goal you can use Extension method which will create DatePicker with default actions. For further information review the following code snippet:
 
namespace Mvc.UI.jQuery 
    public static class TestExtensions 
    { 
        public static DatePickerBuilder DatePickerWithDefaults(this jQueryViewComponentFactory factory) 
        { 
            var builder = factory.DatePicker(); 
            var viewContext = builder.ToComponent().ViewContext; 
            builder.OnBeforeShow(() => { viewContext.HttpContext.Response.Write("function() { alert(\"onBeforeShow\"); }"); }); 
            return builder; 
        } 
    } 

Regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Rommel Manalo
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or