search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Event Click JavaScrip Dyanmically

Asked by Anonymous
17 years ago.

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;

}


Comment posted by Dan Letecky
17 years ago.
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 Anonymous
17 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 Dan Letecky
17 years ago.
The client-side JavaScript object can be specified using ClientObjectName property. E.g.

dpc.ClientObjectName = "dpc1";
Comment posted by Dan Letecky
17 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);";
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.