I'm attempting to make a quick ajax database lookup while the person types in the Postcode field, with the intention that the suburb and state fields populate when a match is made (postcode is 4 numbers so I guess ideally it wouldn't do a lookup until the postcode field is 4 characters in length).
I can achieve this easily hand coding the AJAX, but am having issues getting the RadAjax controls to do the work. The event is definitely firing, the ajaxRequest method just isn't doing anything. Couldn't find any directly applicable examples or documentation although in my mind it would be a commonly done thing. I just must have missed something.
Here is a small clean example of my code (master page is basic HTML and SQL queries are simple lookups on postcode field).
I can achieve this easily hand coding the AJAX, but am having issues getting the RadAjax controls to do the work. The event is definitely firing, the ajaxRequest method just isn't doing anything. Couldn't find any directly applicable examples or documentation although in my mind it would be a commonly done thing. I just must have missed something.
Here is a small clean example of my code (master page is basic HTML and SQL queries are simple lookups on postcode field).
| <%@ Page Language="VB" MasterPageFile="~/legal/Legal.master" AutoEventWireup="false" CodeFile="postcode.aspx.vb" Inherits="legal_postcode" title="Untitled Page" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <asp:Content ID="cntHead" ContentPlaceHolderID="cplHead" Runat="Server"> |
| <script type="text/javascript"> |
| function PostcodeAjax(eventArgs) { |
| <%=radAJAX.ClientID%>.ajaxRequest(eventArgs); |
| } |
| </script> |
| </asp:Content> |
| <asp:Content ID="cntBody" ContentPlaceHolderID="cplBody" Runat="Server"> |
| <asp:ScriptManager ID="scmAJAX" runat="server" /> |
| <telerik:RadAjaxManager ID="radAJAX" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="tbxAddress_Postcode_C"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="tbxAddress_Suburb_C" /> |
| <telerik:AjaxUpdatedControl ControlID="tbxAddress_State_C" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <asp:SqlDataSource ID="sqlSuburbList" runat="server" ConnectionString="<%$ ConnectionStrings:PRM_AFPConnectionString %>" |
| SelectCommand="usp_AFP_AjaxSuburbList2" SelectCommandType="StoredProcedure"> |
| <SelectParameters> |
| <asp:ControlParameter ControlID="tbxAddress_Postcode_C" Name="Postcode" Type="String" PropertyName="Text" Size="4" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| <asp:SqlDataSource ID="sqlStateList" runat="server" ConnectionString="<%$ ConnectionStrings:PRM_AFPConnectionString %>" |
| SelectCommand="usp_AFP_AjaxStateList" SelectCommandType="StoredProcedure"> |
| <SelectParameters> |
| <asp:ControlParameter ControlID="tbxAddress_Postcode_C" Name="Postcode" Type="String" PropertyName="Text" Size="4" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| <asp:Label ID="lblAddress_Postcode_C" AssociatedControlID="tbxAddress_Postcode_C" runat="server" Text="Postcode (AU):" /> |
| <asp:TextBox ID="tbxAddress_Postcode_C" runat="server" onkeyup="PostcodeAjax('tbxAddress_Postcode_C');" MaxLength="4" /> |
| <br /> |
| <asp:Label ID="lblAddress_Suburb_C" AssociatedControlID="ddlAddress_Suburb_C" runat="server" Text="Suburb (AU):" /> |
| <asp:DropDownList ID="ddlAddress_Suburb_C" runat="server" DataSourceID="sqlSuburbList" DataTextField="Suburb" DataValueField="Suburb" /> |
| <br /> |
| <asp:Label ID="lblAddress_State_C" AssociatedControlID="ddlAddress_State_C" runat="server" Text="State (AU):" /> |
| <asp:DropDownList ID="ddlAddress_State_C" runat="server" DataSourceID="sqlStateList" DataTextField="State" DataValueField="State" /> |
| </asp:Content> |