Sample ASP.net 2.0' Client callback

Last post 08-26-2005 10:20 AM by PLBlum. 5 replies.

Sort Posts:

  • Sample ASP.net 2.0' Client callback

    08-24-2005, 7:34 PM
    • Member
      15 point Member
    • abahramiasp
    • Member since 08-18-2005, 7:09 PM
    • Posts 11

    Hi
    I am new to asp 2.0 i am looking for sample code in Vb that demonstrates client Call back in asp 2.0.
    Also i am looking for RichTexBox control in asp 2.0 nothing fancy just a control that can understand rtf.

     

    Any help will be appreciated
    Thanks
    Al

  • Re: Sample ASP.net 2.0' Client callback

    08-25-2005, 1:32 AM
    • All-Star
      45,563 point All-Star
    • haidar_bilal
    • Member since 07-14-2003, 1:43 AM
    • Lebanon - Beirut
    • Posts 8,726
    • TrustedFriends-MVPs
    This question should not be asked here. It should be asked in the General Discussion Forum for ASP.NET 2.0.
    However, check this link: ASP.NET 2.0 CallBack

    regards
    Bilal Hadiar, MCP, MCTS, MCPD, MCT
    Microsoft MVP - Telerik MVP
  • Re: Sample ASP.net 2.0' Client callback

    08-25-2005, 1:34 AM
    • Contributor
      5,684 point Contributor
    • mikepope
    • Member since 07-20-2002, 6:14 AM
    • Seattle, WA
    • Posts 1,136
    • AspNetTeam
      Moderator
    -- Mike Pope

    ASP.NET User Education

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Re: Sample ASP.net 2.0' Client callback

    08-25-2005, 11:17 PM
    • Member
      15 point Member
    • abahramiasp
    • Member since 08-18-2005, 7:09 PM
    • Posts 11

    Thanks, the first link wasnt working for me and  unfortunately none of the sample works with Beta 2. is there a working sample code out there?

  • Re: Sample ASP.net 2.0' Client callback

    08-26-2005, 12:57 AM
    • Contributor
      5,684 point Contributor
    • mikepope
    • Member since 07-20-2002, 6:14 AM
    • Seattle, WA
    • Posts 1,136
    • AspNetTeam
      Moderator
    Shoot -- I've been having problems with connectivity on my server.

    Here's the code.  Code-behind for the page:

    Partial Class CallBack_DB_aspx
    Implements System.Web.UI.ICallbackEventHandler

    Protected ZipTable As Hashtable
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) _
    Handles Me.Load
    ZipTable = New Hashtable()
    ZipTable.Add("98106", "Seattle")
    ZipTable.Add("10270", "New York")
    ZipTable.Add("95110", "San Jose")

    Dim cbReference As String = Page.GetCallbackEventReference(Me, _
    "arg", "GetServerData", "context")
    Dim callbackScript As String = ""
    callbackScript &= "function CallTheServer(arg, context)"
    callbackScript &= vbCrLf & "{"
    callbackScript &= vbCrLf & " " & cbReference & ";"
    callbackScript &= vbCrLf & "}"
    Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), _
    "CallTheServer", callbackScript, True)
    End Sub

    Public Function RaiseCallbackEvent(ByVal eventArgument As String) _
    As String Implements _
    System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
    Dim city As String
    If ZipTable(eventArgument) Is Nothing Then
    city = "Not found"
    Else
    city = ZipTable(eventArgument).ToString()
    End If
    Return city
    End Function
    End Class

    Here's the page:

    <%@ Page Language="VB" AutoEventWireup="false" 
    CompileWith="CallBack_DB.aspx.vb" ClassName="CallBack_DB_aspx" %>

    <html>
    <head runat="server">
    <script type="text/javascript">
    function CityLookup()
    {
    var zip = document.forms[0].zip.value;
    CallTheServer(zip, "");
    }

    function GetServerData(city, context)
    {
    document.forms[0].city.value = city;
    }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <input type="text" id="zip" />
    <br />
    <button onclick="CityLookup()">Look up city</button>
    <br />
    <input type="text" id="city" />
    </div>
    </form>
    </body>
    </htm>

    -- Mike Pope

    ASP.NET User Education

    This posting is provided "AS IS" with no warranties, and confers no rights.

  • Re: Sample ASP.net 2.0' Client callback

    08-26-2005, 10:20 AM
    • All-Star
      30,305 point All-Star
    • PLBlum
    • Member since 06-28-2002, 9:20 AM
    • Boston, MA
    • Posts 5,343
    Be careful. The example shown works for Beta 2 but not for later releases. Microsoft changed the ICallbackEventHandler interface. See http://west-wind.com/weblog/posts/2694.aspx.
    --- Peter Blum
    Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
    www.PeterBlum.com
Page 1 of 1 (6 items)