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

DayPilotBubble1_RenderContent in VB

Asked by Anonymous
11 years ago.

Please, could you help to translate this hereafter to VB, specially "e is RenderEventBubbleEventArgs"

Thanks for your help !

protected void DayPilotBubble1_RenderContent(object sender, RenderEventArgs e)
{
if (e is RenderEventBubbleEventArgs)
{
RenderEventBubbleEventArgs re = e as RenderEventBubbleEventArgs;
re.InnerHTML = "<b>Event details</b><br />Here is the right place to show details about the event with ID: " + re.Value + ". This text is loaded dynamically from the server.<br/><b>Double-click the event to enter inline edit mode.</b>";
}
else if (e is RenderTimeBubbleEventArgs)
{
RenderTimeBubbleEventArgs re = e as RenderTimeBubbleEventArgs;
e.InnerHTML = "<b>Time header details</b><br />From:" + re.Start + "<br />To: " + re.End;
}
else if (e is RenderCellBubbleEventArgs)
{
RenderCellBubbleEventArgs re = e as RenderCellBubbleEventArgs;
e.InnerHTML = "<b>Cell details</b><br />Column:" + re.ResourceId + "<br />From:" + re.Start + "<br />To: " + re.End;
}
}

Answer posted by Richard
11 years ago.

The direct equivalent of "e is MyType" would be "TypeOf e Is MyType":

If TypeOf e Is RenderEventBubbleEventArgs Then
Dim re As RenderEventBubbleEventArgs = TryCast(e, RenderEventBubbleEventArgs)
...

However, the original code is inefficient, as it attempts to cast the value twice for each type. It would be better to use:

var reb = e as RenderBubbleEventArgs;
if (reb != null)
{
...
return;
}

which would translate as:

Dim reb As RenderEventBubbleEventArgs = TryCast(e, RenderEventBubbleEventArgs)
If reb IsNot Nothing Then
...
Return
End If

http://www.developerfusion.com/tools/convert/csharp-to-vb/

Answer posted by Anonymous
11 years ago.

Thank you for your answer! It works fine !

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