Ajax within UserControl loses next field value on postback

9 posts, 0 answers
  1. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 17 Sep 2009 Link to this post

    2009.2.906.35  VS2008 SP1, XP, IE8.

    I was able to isolate to minimally what is needed to reproduce the problem.

    <%@ Page Language="vb" AutoEventWireup="false" enableEventValidation="false" CodeBehind="Default.aspx.vb" Inherits="TestAjax._Default" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!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>Test</title> 
     
    </head> 
    <body> 
        <form id="form1" runat="server"
     
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release"
        </telerik:RadScriptManager> 
         
        Use drop down, then put in value in first textbox, the focus will go to 2nd textbox but you cannot enter anything. 
    <br /> 
    If you click 2nd textbox again, type in, and also fill out 3rd textbox.  [Go], you'll see that the 2nd textbox value gets lost.          
    <br /> 
    If EnableAjax="false" then problem does not exist. 
    <br /> 
    <telerik:RadComboBox ID="cboFunction" EmptyMessage="Select a function" runat="server" AutoPostBack="true"
                            <Items> 
                                <telerik:RadComboBoxItem Text="" /> 
                                <telerik:RadComboBoxItem Text="test1" Value="test1" /> 
                            </Items> 
                            <ExpandAnimation  Type="None" /> 
                            <CollapseAnimation Type="None" /> 
                        </telerik:RadComboBox> 
     
    <br />                     
                    <asp:PlaceHolder ID="myPlaceHolder" runat="server"></asp:PlaceHolder> 
     
                <asp:Button ID="btnGo" runat="server" Width="100px" Text="Go" Enabled="true" /> 
         
                <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" UpdatePanelsRenderMode="Inline" > 
                <AjaxSettings>        
                    <telerik:AjaxSetting AjaxControlID="cboFunction"
                        <UpdatedControls> 
                            <telerik:AjaxUpdatedControl ControlID="myPlaceHolder" /> 
                        </UpdatedControls>               
                    </telerik:AjaxSetting>                                                                        
                </AjaxSettings> 
            </telerik:RadAjaxManager> 
        </form> 
    </body> 
    </html> 
     
    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucTest.ascx.vb" Inherits="TestAjax.ucTest" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
         
    <telerik:RadTextBox runat="server" ID="txtSubAccountNo" AutoPostBack="true" Width="450px"></telerik:RadTextBox> 
    <br /> 
    <telerik:RadTextBox runat="server" ID="txtSubAccountDesc" ReadOnly="true" BackColor="Gainsboro" TabIndex="-1" Width="450px"></telerik:RadTextBox> 
    <br /> 
    <telerik:RadTextBox runat="server" ID="txt2"  Width="450px"></telerik:RadTextBox> 
    <br /> 
    <telerik:RadTextBox runat="server" ID="txt3"  Width="450px"></telerik:RadTextBox> 
    <br /> 

  2. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 17 Sep 2009 Link to this post

    Another scenerio, when I placed the inner postback within AjaxUpdatePanel, I get a:
    Microsoft JScript runtime error:  Unkown runtime error

    pointing to the line indicated by <<<<<<<<<<

    },_applySelection:function(){if(!this._isInVisibleContainer(this._textBoxElement)){return 
    }if((Sys.Browser.agent==Sys.Browser.Opera)||!document.selection){this._textBoxElement.selectionStart=this._selectionStart; 
    this._textBoxElement.selectionEnd=this._selectionEnd; 
    return 
    }this._textBoxElement.select(); <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    sel=document.selection.createRange(); 
    sel.collapse(); 
    sel.moveStart("character",this._selectionStart); 
    sel.collapse(); 

    It seems to only work if I use both as AjaxUpdatePanel...   using AjaxMgr would fail.
  3. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 Sep 2009 Link to this post

    Hi Lenny,

    Could you please check if you have followed the steps described here for loading user controls with ajax?

    If the problem persists, I suggest that you send the server-side code used so I can test the scenario locally.

    Best wishes,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  4. Lenny_shp
    Lenny_shp avatar
    343 posts
    Member since:
    Jul 2006

    Posted 28 Sep 2009 Link to this post

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
            Dim myUserControl As UserControl 
     
            myUserControl = DirectCast(LoadControl("~/ucTest.ascx"), UserControl) 
            myUserControl.ID = "ucTest" '& CType(Int((Rnd() * 1024) + 1), String) 
            myUserControl.EnableViewState = False 
            myPlaceHolder.Controls.Add(myUserControl) 
        End Sub 
     
        Private Sub btnGo_Click(ByVal sender As ObjectByVal e As System.EventArgs) Handles btnGo.Click 
     
            For Each cntrl As Control In myPlaceHolder.Controls(0).Controls 
                If TypeOf (cntrl) Is RadTextBox Then 
                    Response.Write(DirectCast(cntrl, RadTextBox).Text & "<br>"
                End If 
            Next 
     
        End Sub 

    There is only 1 unique control "ucTest" in this project.   If I put RadAjaxPanel (id=ajax2) within the UserControl's UserControl, then it works fine.   Somehow I could not product the Javascript error when combining it with AjaxMgr anymore.

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ucTest.ascx.vb" Inherits="TestAjax.ucTest" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <telerik:RadAjaxPanel runat="server" ID="ajax2"
        <telerik:RadTextBox runat="server" ID="txtSubAccountNo" AutoPostBack="true" Width="450px"
        </telerik:RadTextBox> 
        <br /> 
        <telerik:RadTextBox runat="server" ID="txtSubAccountDesc" ReadOnly="true" BackColor="Gainsboro" TabIndex="-1" Width="450px"
        </telerik:RadTextBox> 
    </telerik:RadAjaxPanel> 
     
    <br /> 
    <telerik:RadTextBox runat="server" ID="txt2"  Width="450px"></telerik:RadTextBox> 
    <br /> 
    <telerik:RadTextBox runat="server" ID="txt3"  Width="450px"></telerik:RadTextBox> 
    <br /> 

  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 01 Oct 2009 Link to this post

    Hello Lenny_shp,

    I tested your code and it worked fine on my end. However, could you please specify what are the ajax settings you have on the main page and what is the expected/desired behavior and results?
     
    Kind regards,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Mikhail
    Mikhail avatar
    2 posts
    Member since:
    Dec 2011

    Posted 22 Feb 2012 Link to this post

    Hi,

    We are having the same problem as described in  the "http://www.telerik.com/community/forums/aspnet-ajax/ajax/ajax-within-usercontrol-loses-next-field-value-on-postback.aspx" dialog. The problem is only present under IE8, IE9 - both Chrome and FireFox a working fine with the code. I can recreate an error. If there was any solution found, please let us know.

    Regards,

    Mikhail Netsmekh

     

      
  7. Vasil
    Admin
    Vasil avatar
    1641 posts

    Posted 24 Feb 2012 Link to this post

    Hi Mikhail,

    The issue that you refer is from before 2 years and a lot of changes was made since then.
    Could you confirm that you use the latest version of the controls?
    We ware unable to confirm the problem in the first place. Could you share with us the code that you use to recreate the error?

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Mikhail
    Mikhail avatar
    2 posts
    Member since:
    Dec 2011

    Posted 24 Feb 2012 Link to this post

    Hi Vasil,

    Our version of Telerik is 2010.2.929.20

     
  9. Vasil
    Admin
    Vasil avatar
    1641 posts

    Posted 27 Feb 2012 Link to this post

    Hello Mikhail,

    Can you insulate the problem with sample code and share it with us so we could observe it and debug it?

    Kind regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top