Home Unanswered Active Tags New Question

Event Click JavaScrip Dyanmically

Hi,
I am creating the DayPilot control dynamically and assigning all the property as well. But how to assign the event click JavaScrip Daynamically? dpc.EventClickJavaScript= "document.location='wfTicketDetail.aspx?id='" + e.value();


foreach (DataRow dr in dsUserCal.Tables[0].Rows)
{
DayPilot.Web.Ui.DayPilotCalendar dpc = new DayPilot.Web.Ui.DayPilotCalendar();
dpc.ID = dr["CalUserId"].ToString();
dpc.DataSource = dsUserEvets;
dpc.DataStartField = "StartDate";
dpc.DataEndField = "EndDate";
dpc.DataTextField = "Organisation";
dpc.DataValueField = "AID";
dpc.StartDate = System.DateTime.Now;
dpc.Days = 1;
dpc.EventClickHandling = DayPilot.Web.Ui.Enums.EventClickHandlingEnum.JavaScript;

}


Asked by Anonymous 4 years ago.
Replies
The code should look like this:

dpc.EventClickJavaScript= "document.location='wfTicketDetail.aspx?id=' + e.value();";

The " + e.value()" part is JavaScript and it must be inside the quotation marks.
Comment posted by Dan Letecky 4 years ago.
I need to change the script dynamically like below.

if (e.Value.Substring(1, 1) == "t")
{
<How to I get the object which I created dynamically>.EventClickJavaScript = "document.location='wfTdts.aspx?id=' + e.value()";
}
else
{
<How to I get the object which I created dynamically>.EventClickJavaScript =
"document.location='wfOpdts.aspx?id=' + e.value()";
}
Comment posted by Anonymous 4 years ago.
The client-side JavaScript object can be specified using ClientObjectName property. E.g.

dpc.ClientObjectName = "dpc1";
Comment posted by Dan Letecky 4 years ago.
However, changing the EventJavaScript in BeforeEventRender handler won't work (the one that you set last will be used).

You need to move this code to the client side:
<script type="text/javascript">
function clickHandler(e) {
if (e.value().substring(1,2) == 't') {
document.location = 'wfTdts.aspx?id=' + e.value();
}
else {
document.location = 'wfOpdts.aspx?id=' + e.value();
}
}
</script>
and
dpc.EventClickJavaScript = "clickHandler(e);";
Comment posted by Dan Letecky 4 years ago.
New Reply
This reply is
Your name (optional):

DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java