Source Code

for file /controls/LookUp.ascx

<%@ Control Language="C#" EnableViewState="true" AutoEventWireup="false" ClassName="LookUp" Inherits="AJAXControls.BaseControl" 
  Description="Implementation of an INPUT field with a LookUp helper" %>
<%@ Implements Interface="System.Web.UI.IPostBackDataHandler" %>
<%
  // Lookup.ascx
  // Implementation of the LookUp AJAX Control
  // Copyright (c) by Matthias Hertel, http://www.mathertel.de
  // This work is licensed under a BSD style license. See http://www.mathertel.de/License.aspx
  // ---
  // 12.08.2005 created
  // 26.10.2007 inheriting from BaseControl
%>
<script runat="server">
  // [ValidationProperty("Value")]

  public string name = null;
  public string eventname = String.Empty;

  public string lookupservice = null;
  public bool nosubmit = false;
  public string Value = null;


  protected override void OnPreRender(EventArgs e) {
    base.OnPreRender(e);
    base.RegisterBehavior("lookup");
  } // OnPreRender


  // ----- implement IPostBackDataHandler Members to enable embedding into ASP.NET Forms -----

  public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection) {
    string postedValue = postCollection[postDataKey];

    if ((Value == null) || (Value != postedValue)) {
      Value = postedValue;
      return true;
    }
    return false;
  } // LoadPostData


  public void RaisePostDataChangedEvent() {
    // no PostDataChangedEvent will be raised.
  }
</script>
<%// UI for the control %>
<input id="<%=this.ClientID %>" autocomplete="off" eventname="<%=this.eventname %>"
  lookupservice="<%=this.lookupservice %>" name="<%=this.name %>" value="<%=this.Value %>"
  nosubmit="<%=this.nosubmit %>" style="width: 200px" /><img
    class="INPUTFUNC" src="<%=Page.ResolveUrl("~/controls/images/drop.gif") %>" alt="open the LookUp list"
    onclick="document.getElementById('<%=this.ClientID %>').ToggleDropdown()" unselectable="on" />
<script defer="defer" type="text/javascript">jcl.LoadBehaviour("<%=this.ClientID %>", LookUpBehaviour);</script>


This page is part of the http://www.mathertel.de/ web site.

For updates and discussions see http://ajaxaspects.blogspot.com/.