locked
set ajaxFileUpload ContextKey dinamically RRS feed

  • Question

  • User-867857476 posted

    Hi Guys,

    I need to set ajaxFileUpload ContextKey dinamically,

    normal ways not work like:

    AjaxFileUpload1.ContextKey=BlaBla;

    how can i do this?

    Saturday, October 19, 2013 3:54 PM

Answers

All replies

  • User-1635195291 posted

    Hi MostafaTaghipour,

    One way is using JavaScript:

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            function SetContextKey() {
                $find('<%=AutoCompleteExtender1.ClientID>%').set_contextKey("221");
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:TextBox ID="txtContactsSearch" runat="server" onkeyup="SetContextKey()"></asp:TextBox>
        <cc1:AutoCompleteExtender ServiceMethod="SearchCustomers" MinimumPrefixLength="2"
            CompletionInterval="100" EnableCaching="false" CompletionSetCount="10" TargetControlID="txtContactsSearch"
            UseContextKey="true" ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false">
        </cc1:AutoCompleteExtender>
        </form>
    </body>
    </html>

    Source: ASP.NET AJAX AUTOCOMPLETEEXTENDER: DYNAMICALLY SET CONTEXTKEY USING JAVASCRIPT

    or else:

    Hope this helps.

    Thanks,

    Jatin

    Sunday, October 20, 2013 11:08 PM
  • User-867857476 posted

    Thanks Jatin,

    but this solutions not work

    Monday, October 21, 2013 11:39 AM
  • User-933407369 posted

     hi MostafaTaghipour,

     i would suggest you to download sources from here: http://ajaxcontroltoolkit.codeplex.com/SourceControl/BrowseLatestand change  AjaxFileUpload.cs file (here is a path:/Server/AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs).

    http://ajaxcontroltoolkit.codeplex.com/sourcecontrol/latest#Server/AjaxControlToolkit/AjaxFileUpload/AjaxFileUpload.cs

    What you need to do is to change ContextKey constant to property for combining context key guid with unique id of control.Try to alter AjaxFileUpload.cs code below:

    public class AjaxFileUpload : ScriptControlBase
    {
        private const string ContextKeySuffix = "{DA8BEDC8-B952-4d5d-8CC2-59FE922E2923}";
    
        private string ContextKey
        {
            get { return this.UniqueID + "_" + ContextKeySuffix; }
        }
       .....
    }

    And then you can use the new AjaxFileUpload.cs file.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, October 22, 2013 8:07 AM