Forum  General Visual ...  Visual WebGui v...  JS Custom control migration 6.3 to 6.4
Previous Previous
 
Next Next
New Post 11/10/2010 6:18 AM
  rschnell
429 posts
2nd Level Poster


JS Custom control migration 6.3 to 6.4 

 Hi

I have been using a custom Js function to get the cient's date time to do time zone conversions on the server. In 6.4 this no longer works. The function  called at InvokeMethodWithId("TMZ_calcTime", Offset), i.e. TMZ_cLalcTime is not found at run time (and it IS registered). I suppose this is due to the different way of doing this in 6.4.

Note the function  raises and event Events_Createevent etc. When I try to convert the function to call it simply via InvokeScript, these fail due I think to a name space issue.

What;s the best way of resolving all this with minimum changes to what has already been done?

 

Regards

 

Richard

 

 
New Post 11/10/2010 6:20 AM
  rschnell
429 posts
2nd Level Poster


Re: JS Custom control migration 6.3 to 6.4 

 This is the original post containing the js code:

 

http://www.visualwebgui.com/Developers/Forums/tabid/364/forumid/29/threadid/14021/scope/posts/threadpage/2/Default.aspx

 
New Post 11/11/2010 12:53 AM
  rschnell
429 posts
2nd Level Poster


Re: JS Custom control migration 6.3 to 6.4 

 Help, this is getting to be urgent. Richard

 
New Post 11/13/2010 6:02 AM
  palli
14298 posts
1st Level Poster




Re: JS Custom control migration 6.3 to 6.4 

Hi Richard,

Sorry for your troubles.

The resource mechanism changed dramatically between 6.3 and 6.4, so it is most likely your problem here to get the resource to the client. There is a new article on the Wiki which is a kind of walkthrough article on how to get a script out to the client. You may be interested in viewing it to know the steps.

As this is becoming urgent, I can also offer you that you email a simple project to support that does include this resource and set up like you think it should be, including some sample code on how you use it, and I will check it for you and see if I can make it work. Like I said, this is most likely related to the change in resource management.

Hope this helps,

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 11/15/2010 5:05 PM
  rschnell
429 posts
2nd Level Poster


Re: JS Custom control migration 6.3 to 6.4 

 Hi Palli,

 

Ye understand they are different mechanisms in 6.4, but note this script is not related to any visual component and creating a custom control seems an over-kill. So to be precise what I was referring to is illustrated in the code below. This code, transcribed from the old code, does not fail. However the "call back" events do not fire. I suppose this is some name space thing?

 

Regards

 

richard

 

Public Class TMZ

    Private mstrClientTimeZone As String = String.Empty

    Private mstrClientTime As String = String.Empty

    Public Sub New()

 

        ' This call is required by the Windows Form Designer.

        InitializeComponent()

 

        ''MyBase.TagName = "TM58.TMZ"

 

    End Sub

 

    Protected Overrides Sub RenderAttributes(ByVal context As Gizmox.WebGUI.Common.Interfaces.IContext, ByVal writer As Gizmox.WebGUI.Common.Interfaces.IAttributeWriter)

        MyBase.RenderAttributes(context, writer)

 

        writer.WriteAttributeString(Gizmox.WebGUI.WGAttributes.Text, Me.Text)

 

    End Sub

    Protected Overloads Overrides Sub FireEvent(ByVal objEvent As IEvent)

        MyBase.FireEvent(objEvent)

        Select Case objEvent.Type

            Case "ClientTimeZone"

                mstrClientTimeZone = objEvent("TimeZone")

                '

                ' UTC time plus server offset

                '

                User.ServerTimeString = mstrClientTimeZone

                mstrClientTime = objEvent("Time")

                User.ServerTimeString = DateTime.Now

                '

                ' Client time

                '

                If mstrClientTime.Contains("GMT") Then

                    mstrClientTime = mstrClientTime.Split("GMT")(0)

                End If

 

                User.UserTimeString = mstrClientTime

 

                User.OffsetUserFromServer = DateDiff("h", User.ServerTimeString, mstrClientTime)

                User.LogMsg(User.SubID, User.UserID, _

          "Offset Of User From Server", "Offset : " & User.OffsetUserFromServer & " Server : " & User.ServerTimeString & " Client :" & User.UserTimeString)

 

 

                Exit Select

        End Select

    End Sub

    Public Overrides Property Text() As String

        Get

            Return MyBase.Text

        End Get

        Set(ByVal value As String)

            If Not (MyBase.Text = value) Then

                MyBase.Text = value

                Me.Update()

            End If

        End Set

    End Property

    Private User As TMUser.clsG

    Public Property TMUser() As TMUser.clsG

        Get

            Return User

        End Get

        Set(ByVal Value As TMUser.clsG)

            User = Value

        End Set

    End Property

    Public Property ClientTimeZone() As String

        Get

            Return mstrClientTimeZone

        End Get

        Set(ByVal value As String)

            mstrClientTimeZone = value

 

        End Set

    End Property

    Public Sub Register()

        RegisterSelf()

    End Sub

    Public Sub UnRegister()

        UnRegisterSelf()

    End Sub

    Public Sub InitializeTimeZone(ByVal Offset As String)

      

        'InvokeMethodWithId("TMZ_calcTime", Offset)

        '

        ' Replace 6.3 method with 6.4

        '

        Dim Javascript As String = GetScript(Offset)

        InvokeScript(Javascript)

    End Sub

    Private Function GetScript(ByVal Offset As String) As String

        GetScript = "function TMZ_calcTime(strGuid, offset)" & _

    "{d = new Date();utc = d.getTime() +     (d.getTimezoneOffset() * 60000);" & _

    "nd = new Date(utc + (3600000 * offset));" & _

    "var objEvent = Events_CreateEvent(strGuid, 'ClientTimeZone', null, true);" & _

    "Events_SetEventAttribute(objEvent, 'TimeZone', nd.toLocaleString());" & _

    "var objEvent1 = Events_CreateEvent(strGuid, 'ClientTime', null, true);" & _

    "Events_SetEventAttribute(objEvent, 'Time', d.toLocaleString());" & _

    "Events_RaiseEvents();};TMZ_calcTime( 'TMZ_CalcTime'," & Offset & ");"

    End Function

 

End Class

 
Previous Previous
 
Next Next
  Forum  General Visual ...  Visual WebGui v...  JS Custom control migration 6.3 to 6.4
.NET HTML5 Web, Cloud and Mobile application delivery | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2012 Visual WebGui®       Visual WebGui weblog on ASP.NET Gizmox Blog Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS