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

UpdateWithMessage change color MessageBox from behind

Asked by Anonymous
4 months ago.

HI,

in the ASP.NET WebForm project I have the DayPilotScheduler1 and I would like to customize the color of the message when I try to modify a schedule directly with drag and drop.

I would like to display the message with a red background when the modification is not allowed, and in green when the modification was successful.

Thank you

Protected Sub DayPilotScheduler1_EventMove(ByVal sender As Object, ByVal e As DayPilot.Web.Ui.Events.EventMoveEventArgs)

    If e.OldEnd <= Date.Today Then
        Dim message As String = "You can't move!"
        LoadResourcesAndEvents()
        DayPilotScheduler1.UpdateWithMessage(message)
        Exit Sub
    End If

End Sub
Answer posted by Dan Letecky [DayPilot]
4 months ago.

It is not possible with UpdateWithMessage() but you can use Update() to send custom data to the client and display the message bar using JavaScript using a custom CSS class.

Hashtable ht = new Hashtable();
ht["message"] = "Hi there";
ht["cssClass"] = "red-message";
DayPilotScheduler1.Update(ht);

You need to define an AfterRenderJavaScript event handler:

<DayPilot:DayPilotScheduler id="DayPilotScheduler1" runat="server" 
  ...
  AfterRenderJavaScript="afterRender(data);"
  ClientObjectName="scheduler"
></DayPilot:DayPilotScheduler>

And the JavaScript function which will display the message using the message() method:

<script>
function afterRender(data) {
  if (data && data.message) {
    scheduler.message(data.message, {cssClass: data.cssClass});
  }
}
</script>

And of course, you need to define the CSS class:

.red-message {
  background-color: red;
}
Comment posted by Simone
4 months ago.

Thanks, it work very good!

Regards

Simone

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.