title: AJAX AutoComplete Extender - set ContextKey Paramerter-value & pass it to WebMethod along with the prefixText
body: <p>after learning about the AutoComplete Attribute - <code>ContextKey</code> </p>
  
  <p>i am using it as an advantage :</p>
  
  <p>the data source of every extender object will be handled by same WebMethod.</p>
  
  <p>that by it self, is an achivement for me . </p>
  
  <p>now that every thing is allmost perfect, the problem is:</p>
  
  <p>I need to pass another parameter, when request for AutoComplete-Datasource is sent by the Second Textbox, right after the stage = table was selected . </p>
  
  <p>so now i need , not only the hardcoded/constant, but also the value of the selected table.</p>
  
  <p>which is actually the value of <code>#TBX_TableSelectorFirstStage</code>, along with the hardcoded <code>ContextKey</code> value...</p>
  
  <p>(something like <code>ContextKey += value of TBX_TableSelectorFirstStage</code>)</p>
  
  <p>so i could then be able to draw the specified Columns list by requested  table (the table's name)</p>
  
  <p>this is <strong><em><code>Jquery</code> Code</em></strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
     $('document').ready(function () {
  
         var IvalidValue_Msg = "table was not selected";
         var TBX_tables = $(this);
  
         var TBX_Columns = $('#TBX_ColumnsSelectorFirstStage');
  
  
         $('#TBX_TableSelectorFirstStage')
         .val("Choose a Table")
         .focus(function () {
  
             $(this).val("");
             $(this).attr("dir", "ltr");
  
         }).blur(function () {
             var TBXTablsVALUE = $('#TBX_TableSelectorFirstStage').val();
             var Lngth = $('#TBX_TableSelectorFirstStage').val().length;
             var InvalidTBXBlur_TablesValue = TBXTablsVALUE == "" || TBXTablsVALUE == " " || Lngth &lt; 4;
             if (InvalidTBXBlur_TablesValue) {
                 $(this).focus();
                 $(this).val(IvalidValue_Msg);
             }
             else {
  
                 $(TBX_Columns).focus();
                 SetContextKeyValue();
             }
             //$(this).next(':input').focus();
  
         }).change(function () {
             var TBXTablsVALUE = $('#TBX_TableSelectorFirstStage').val();
             var Lngth = $('#TBX_TableSelectorFirstStage').val().length;
             var InvalidTBXBlur_TablesValue = TBXTablsVALUE == "" || TBXTablsVALUE == " " || Lngth &lt; 4;
  
             if (InvalidTableValue) {
                 $(this).val(IvalidValue_Msg);
             }
             else {
                 SetContextKeyValue();
             }
         }).click(function () {
  
  
                 $(this).val("");
  
         });
     });
          /// ==========================================================\\\
         ///Jquery Section That Is Suppose To manipulate contextKey Property.
  
         function SetContextKeyValue() {
       //  var ttt = $get('AjaxAcEx_Columns_FirstStage',
         alert("asasas");
         // var x = $('#AutoCompleteExtender3'); //.set_contextKey($get('AjaxAcEx_Tables_FirstStage').value);
         alert($('#AjaxAcEx_Columns_FirstStage').attr("id")); 
     }
  </code></pre>
  
  <p></p>
  
  <p>this is the <strong><em>ASPX Code</em></strong></p>
  
   <pre class="lang-aspx prettyprint-override"><code>&lt;form id="form1" runat="server"&gt;
  &lt;cc1:ToolkitScriptManager ID="ToolKitScrptMan1" runat="server"&gt;&lt;/cc1:ToolkitScriptManager&gt;
  
  &lt;cc1:AutoCompleteExtender ID="AutoCompleteExtender1" TargetControlID="TBX_FntsAC" runat="server"
                           MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="100" 
                           ServiceMethod="MyAcReqHandler" ContextKey="acFontsRquest"
                           FirstRowSelected="true" CompletionListCssClass="CL_Css_DataBase" CompletionListItemCssClass="CL_ItemCss_DataBase" CompletionListHighlightedItemCssClass="CL_tHighlightedItemCss_DataBase"&gt;
  &lt;/cc1:AutoCompleteExtender&gt;
  &lt;cc1:AutoCompleteExtender ID="AutoCompleteExtender2" BehaviorID="AjaxAcEx_Tables_FirstStage" TargetControlID="TBX_TableSelectorFirstStage" runat="server"
                           MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="100"
                           ServiceMethod="MyAcReqHandler" ContextKey="acTablesSelector_FirstStage"
                           FirstRowSelected="true" CompletionListCssClass="CL_Css_DataBase" CompletionListItemCssClass="CL_ItemCss_DataBase" CompletionListHighlightedItemCssClass="CL_tHighlightedItemCss_DataBase"&gt;
  &lt;/cc1:AutoCompleteExtender&gt;
  
  
  &lt;%--  Here is where i am stuck .
       object /element -  AutoCompleteExtender3 / BehaviorID AjaxAcEx_Columns_FirstStage
      This is the object i need to Set it's ContextKey attribute-value,
       with the result value of #TBX_TableSelectorFirstStage
  --%&gt;
  
  &lt;cc1:AutoCompleteExtender ID="AutoCompleteExtender3" BehaviorID="AjaxAcEx_Columns_FirstStage" TargetControlID="TBX_ColumnsSelectorFirstSTage" runat="server"
                           MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="1" CompletionInterval="100"
                           ServiceMethod="MyAcReqHandler" ContextKey="acColumnsSelector_FirstStage"
                           FirstRowSelected="true" CompletionListCssClass="CL_Css_DataBase" CompletionListItemCssClass="CL_ItemCss_DataBase" CompletionListHighlightedItemCssClass="CL_tHighlightedItemCss_DataBase"&gt;
  &lt;/cc1:AutoCompleteExtender&gt;
  
  
  &lt;div id="Div_firstStage" runat="server" style="width:90%" dir="rtl"&gt;
      &lt;asp:TextBox ID="TBX_TableSelectorFirstStage"  runat="server" /&gt;
      &lt;asp:TextBox ID="TBX_ColumnsSelectorFirstStage" runat="server" /&gt;   
  
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>* .Cs Code Behind*</strong> (webMethod)</p>
  
   <pre class="lang-aspx prettyprint-override"><code>[System.Web.Script.Services.ScriptMethod()]
  [System.Web.Services.WebMethod(EnableSession = true)]
  
  public static List&lt;string&gt; MyAcReqHandler(string prefixText, string contextKey)
  {
  
      List&lt;string&gt; retListAC = new List&lt;string&gt;();
      switch (contextKey)
      {
  
          case AutoComplete.Param.acTablesSelector_FirstStage:
              retListAC = GetListForAutoComplete&lt;HTDB_Tables&gt;(App.VarNms.SesDbTablsList);
              break;
          case AutoComplete.Param.acColumnsSelector_FirstStage:
              retListAC = GetListForAutoComplete&lt;HTDB_Cols&gt;(App.VarNms.SesDbTablsList);
              break;
          case AutoComplete.Param.acFontsRquest_SecondStage:
              retListAC = GetListForAutoComplete&lt;fntNams&gt;(App.VarNms.SesFontsList);
              break;
  
      }
  
      return AutoComplete.FromListStr(prefixText, retListAC);
  }
  
  
  
  private static List&lt;string&gt; GetListForAutoComplete&lt;TheClassNameHere&gt;(string SessionVarName, string NestedClassName="")
  {
      List&lt;string&gt; ReturnedList = new List&lt;string&gt;();
      if (CurrSesVarSet.SesVar_AcDsListStr.Count == 0)
      {
          bool isNested = typeof(TheClassNameHere).IsNested;
          switch (isNested)
          {
              case true:
                  ReturnedList = RflectMeths.anyNestedClassFldsAsListByType&lt;TheClassNameHere&gt;(NestedClassName);
                  break;
              default:
                  ReturnedList = RflectMeths.anyClassFldsAsListByType&lt;TheClassNameHere&gt;();
                  break;
          }
  
  
  
          CurrSesVarSet.SesVar_AcDsListStr = ReturnedList;
          CurrentSession.AddVar(SessionVarName, ReturnedList);
      }
      else
          if (CurSessionMesthods.VarExistStat(App.VarNms.SesFontsList))
               ReturnedList = CurSessionMesthods.GetSessionVar.AsListStr(SessionVarName);
          else ReturnedList = CurrSesVarSet.SesVar_AcDsListStr;
      return ReturnedList;
  }
  </code></pre>
  
  <p>as one of the efforts in this application was  to <strong>avoid full post back</strong> ,  I would like to implement - setting the <code>ContextKey</code>, via <code>Jquery</code> , ... <strong>unless</strong> I am wrong with my base assumption, that doing it through c# - code behind will result in a full page post back , so if it's done without a page reload i should not care as long as i coud get this parameter sent, as until now I have maintained a desktop like user experience (;</p>
  
  <p>thanks for your help, solving this will be really appreciated ! </p>