Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AspDotNetStoreFront
  Ads  
 


  Sponsors  

Meet Our Sponsors

DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
Jango Studios - Skins, Modules and Hosting for DotNetNuke
eUKhost.com is commited to offer exceptional UK Windows Web Hosting solutions with quality 24x7 technical support.Our plans support ASP.Net, ASP, ASP.NET Ajax extensions, XML, MSSQL, MySQL, PHP,DNN, multiple domains and Shared SSL as standard.
SmarterTools
Verndale
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  My first live page using ClientAPI. Hurrah!
Previous Previous
 
Next Next
New Post 3/14/2006 2:31 AM
User is offline John Braga
73 posts
10th Ranked


My first live page using ClientAPI. Hurrah! 

I have a site at www.Stodden.org/Church and if you go there and choose the "Services" page, you can move forward and backward through the monthly schedule - and this is done via the ClientAPI.  It is MUCH quicker than the previous version which used the conventional postback.

Now that I have the first experiment working I will be looking for other pages to convert!

John B

 

 
New Post 3/14/2006 9:49 AM
User is offline Jon Henning
1622 posts
www.codeendeavors.com
5th Ranked










Re: My first live page using ClientAPI. Hurrah! 

Nice work!

One suggestion.  Make sure you finish your javascript code with a semi-color (;), specifically, chservice.js.


 
New Post 3/14/2006 11:04 AM
User is offline John Braga
73 posts
10th Ranked


Re: My first live page using ClientAPI. Hurrah! 

Noted.  Thanks!

 

 
New Post 4/3/2006 1:19 PM
User is offline Kyle Parker
131 posts
9th Ranked


Re: My first live page using ClientAPI. Hurrah! 

Nice use of the ClientAPI!

Would you mind sharing your code? ... I'm trying to get a understanding of the ClientAPI.

Thanks!

 
New Post 5/2/2006 11:34 AM
User is offline John Braga
73 posts
10th Ranked


Re: My first live page using ClientAPI. Hurrah! 

This is the vb code behind - but bear in mind that it is a first attempt, so may not be "best practice".  The ascx page is just a simple datalist, but there are 2 hidden fields TxtPrev and TxtNext containing the dates of the start of the months.

*************************************************************

Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.UI.Utilities
Imports DotNetNuke.UI.Utilities.ClientAPI

Namespace Crownsys.Modules.ChService

    ''' -----------------------------------------------------------------------------
    Partial Class ViewChService
        Inherits Entities.Modules.PortalModuleBase
        Implements Entities.Modules.IActionable
        Implements IClientAPICallbackEventHandler

        Dim LastCaDesc As String = ""
        Dim startd As DateTime

#Region "Event Handlers"
        ''' -----------------------------------------------------------------------------
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try

                If ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XMLHTTP) _
                        AndAlso ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XML) Then
                    ClientAPI.RegisterClientReference(Me.Page, ClientAPI.ClientNamespaceReferences.dnn_xml)
                    ClientAPI.RegisterClientReference(Me.Page, ClientAPI.ClientNamespaceReferences.dnn_xmlhttp)

                    'Only this line will be necessary after 3.2
                    Me.btPrev.Attributes.Add("onclick", ClientAPI.GetCallbackEventReference(Me, _
                        "dnn.dom.getById('" & Me.txtPrev.ClientID & "').value", _
                        "successFunc", _
                        "'" & Me.ClientID & "'", _
                        "errorFunc"))

                    Me.btNext.Attributes.Add("onclick", ClientAPI.GetCallbackEventReference(Me, _
                        "dnn.dom.getById('" & Me.txtNext.ClientID & "').value", _
                        "successFunc", _
                        "'" & Me.ClientID & "'", _
                        "errorFunc"))

                    If Page.ClientScript.IsClientScriptBlockRegistered("chservice.js") = False Then
                        Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "chservice.js", "<script language=javascript src=""" & Me.ModulePath & "chservice.js""></script>")
                    End If

                End If

                If Not Page.IsPostBack() Then
                    If Session("SchedStartDate") Is Nothing Then
                        startd = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
                        Session("SchedStartDate") = startd
                    Else
                        startd = CType(Session("SchedStartDate"), DateTime)
                    End If
                    txtPrev.Text = startd.AddMonths(-1).ToString()  ' hidden field
                    txtNext.Text = startd.AddMonths(1).ToString()   ' hidden field

                    lblAJAX.Text = GetTableOfServices(startd)

                    If Session("SchedStartDate") Is Nothing Then
                        startd = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)
                    Else
                        startd = CType(Session("SchedStartDate"), DateTime)
                    End If

        
                End If

            Catch exc As Exception        'Module failed to load
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

        Protected Sub lstContent_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles lstContent.ItemDataBound
            Dim strContent As String = ""
            Dim info As ChSuperServiceInfo = e.Item.DataItem

            Dim lblHdr As Label = CType(e.Item.FindControl("lblHdr"), Label)

            If LastCaDesc <> info.CaDesc Then
                LastCaDesc = info.CaDesc
                lblHdr.Text = LastCaDesc
            Else
                lblHdr.Text = ""
            End If

            ' assign the content
            Dim lblType As Label = CType(e.Item.FindControl("lblType"), Label)
            Dim lblTime As Label = CType(e.Item.FindControl("lblTime"), Label)
            Dim lblLoc As Label = CType(e.Item.FindControl("lblLoc"), Label)
            Dim lblSDesc As Label = CType(e.Item.FindControl("lblSDesc"), Label)
            lblType.Text = info.ServiceType()
            lblTime.Text = info.Time()
            lblLoc.Text = info.Loc()
            lblSDesc.Text = info.SDesc()
        End Sub

#End Region

#Region "Optional Interfaces"

etc

#End Region

#Region "Private Functions"

        Private Function GetServiceList() As List(Of ChSuperServiceInfo)
            Dim objChServices As New ChServiceController
            Dim colChServices As List(Of ChSuperServiceInfo)
            Dim d2 As DateTime = New DateTime(startd.Year, startd.Month, startd.Day)
            d2 = startd.AddMonths(1).AddDays(7)
            ' 1 greater than what we need
            ' get the content from the ChService table
            colChServices = objChServices.GetChServices(ModuleId, startd, d2)

            ' bind the content to the repeater if testing against original code
            'lstContent.DataSource = colChServices
            'lstContent.DataBind()
            Return colChServices

        End Function

        Private Function GetTableStart() As String
            Return "<table width=""100%px"" cellpadding=""1"" border=""0"">"
        End Function

        Private Function GetCaDescRow(ByVal caservice As String) As String
            Return "<tr><td colspan=""4"" class=""SubHead"">" & caservice & "</td></tr>"
        End Function

        Private Function GetMonthRow(ByVal startd As Date) As String
            Return "<tr><td colspan=""4"" ><h2>" & String.format("Schedule for {0}", startd.ToString("MMMM yyyy")) & _
                      "</h2></td></tr>"
        End Function

        Private Function GetTableEnd() As String
            Return "</table>"
        End Function

        Private Function GetTableOfServices(ByVal startd As Date) As String
            Dim listServices As List(Of ChSuperServiceInfo) = GetServiceList()
            Dim sz As String = GetTableStart() & GetMonthRow(startd)
            Dim caservice As String = ""
            Dim chSuper As ChSuperServiceInfo
            For Each chSuper In listServices
                If caservice <> chSuper.CaDesc Then
                    caservice = chSuper.CaDesc
                    sz += GetCaDescRow(caservice)
                End If

                sz += chSuper.ServiceRow(IsEditable(), EditUrl("sid", chSuper.Sid))

            Next
            sz += GetTableEnd()

            Return sz
        End Function
#End Region
       
        Public Function RaiseClientAPICallbackEvent(ByVal eventArgument As String) As String Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler.RaiseClientAPICallbackEvent
            startd = CType(eventArgument, Date)
            Session("SchedStartDate") = New DateTime(startd.Year, startd.Month, 1)
            Return startd.AddMonths(-1).ToString() & "|" & _
               startd.AddMonths(1).ToString() & "|" & GetTableOfServices(startd)
        End Function

    End Class

End Namespace

and this is the little javascript file chservic.js:

 

function successFunc(result, ctx)
{
 var splits = result.split("|");
 dnn.dom.getById(ctx + '_lblAJAX').innerHTML = splits[2];
    dnn.dom.getById(ctx + '_txtPrev').value = splits[0];
 dnn.dom.getById(ctx + '_txtNext').value = splits[1];

   //  alert('result: ' + result + '\ncontext:' + ctx);
}


function errorFunc(result, ctx)
{
 alert(result);
}


Hope that helps!

 

 
Previous Previous
 
Next Next
  Forum  DotNetNuke® Pro...  ClientAPI Compo...  My first live page using ClientAPI. Hurrah!
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, please observe the following posting guidelines:

1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


Web Development and Strategy Firm
The Risdall Interactive Agency s websites, strategies, branding, & promotion in digital space.
www.Risdall.net/
Windsor Management Group
Fund Accounting Software for K12 Education.
Infinitevisions.com
Convert Visitors to Customers
In order to bring value to your users, we must first understand them. VIVIDSITES will help you build a custom web application and interactive marketing tools that your users will thank you for. We marry high-end creative with head banging technology to entertain and convert visitors into paying customers. Call 314.514.0505 or visit us at http://www.vividsites.com to find out how.
- V I V I D S I T E S -

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP