This is a migrated thread and some comments may be shown as answers.

Ajax within UserControl loses next field value on postback

8 Answers 134 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lenny_shp
Top achievements
Rank 2
Lenny_shp asked on 17 Sep 2009, 03:35 PM
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 /> 

8 Answers, 1 is accepted

Sort by
0
Lenny_shp
Top achievements
Rank 2
answered on 17 Sep 2009, 07:30 PM
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.
0
Iana Tsolova
Telerik team
answered on 23 Sep 2009, 09:08 AM
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.
0
Lenny_shp
Top achievements
Rank 2
answered on 28 Sep 2009, 03:06 PM
    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 /> 

0
Iana Tsolova
Telerik team
answered on 01 Oct 2009, 10:03 AM
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.
0
Mikhail
Top achievements
Rank 1
answered on 22 Feb 2012, 10:05 PM
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

 

  
0
Vasil
Telerik team
answered on 24 Feb 2012, 01:29 PM
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.
0
Mikhail
Top achievements
Rank 1
answered on 24 Feb 2012, 02:44 PM
Hi Vasil,

Our version of Telerik is 2010.2.929.20

 
0
Vasil
Telerik team
answered on 27 Feb 2012, 06:35 PM
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.
Tags
Ajax
Asked by
Lenny_shp
Top achievements
Rank 2
Answers by
Lenny_shp
Top achievements
Rank 2
Iana Tsolova
Telerik team
Mikhail
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or