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

How to pass javascript for client-side eval from DayPilot event (cont.)

Asked by Dirk Louwers
16 years ago.
Hi Dan,

A shameless new thread since old ones tend to be overlooked:

"You can use DayPilotCalendar.Update(data) method on the server-side to pass a custom parameter (data - a string or a Hashtable) to the client side."

I can just pass my parameters directly into theJS function I will be calling client side. Is it still neccesary to update for theJSto be executed?

"Then specify AfterRenderJavaScript property: It will contain the JavaScript code to be executed after CallBack (in fact it's executed always after the rendering is finished). Your "data" form Update() method will be available as "data" variable. If you pass a Hashtable, it will be evaluated into an object, e.g. data["Result"] will be available as data.Result."

I have triedmyCalendar.AfterRenderJavaScript = "alert('TEST');"; unfortunately this doesn't seem to get executed client side. Is this a bug I should report or are there some other factors to take into account?

"A working example can be found in Demo/Calendar/Default.aspx."

Unfortunately the example mentioned does not demonstrate the use of #AfterRenderJavaScript. Any pointers?
Comment posted by Dan Letecky
16 years ago.
Hi Dirk,

Sorry for the delay, I was out of office.

"You can use DayPilotCalendar.Update(data) method on the server-side to pass a custom parameter (data - a string or a Hashtable) to the client side."

I can just pass my parameters directly into theJS function I will be calling client side. Is it still neccesary to update for theJSto be executed?

If you don't need to pass any parameter back to the client, you can call plain .Update(). But you still need to call it, otherwise the client won't be updated after a CallBack (it won't redraw the events and it won't call AfterRenderJavaScript).

"Then specify AfterRenderJavaScript property: It will contain the JavaScript code to be executed after CallBack (in fact it's executed always after the rendering is finished). Your "data" form Update() method will be available as "data" variable. If you pass a Hashtable, it will be evaluated into an object, e.g. data["Result"] will be available as data.Result."

I have triedmyCalendar.AfterRenderJavaScript = "alert('TEST');"; unfortunately this doesn't seem to get executed client side. Is this a bug I should report or are there some other factors to take into account?


If you call myCalendar.AfterRenderJavaScript during a CallBack, it won't have any effect. During a CallBack it's possible to change only a limited set of properties (in version 4.3 of DayPilotCalendar, it's only StartDate and Days). That's why Update(string) is helpful - you should assign AfterRenderJavaScript just once and use the parameters in switch() {} block to determine the action on the client side.

"A working example can be found in Demo/Calendar/Default.aspx."

Unfortunately the example mentioned does not demonstrate the use of #AfterRenderJavaScript. Any pointers?

You need to look into .aspx not .aspx.cs. It demonstrates the use I described above:

<DayPilot:DayPilotCalendar ...
AfterRenderJavaScript="afterRender(data);"></DayPilot:DayPilotCalendar>
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.