ASP label control disappears

4 posts, 0 answers
  1. RICARDO
    RICARDO avatar
    2 posts
    Member since:
    May 2012

    Posted 04 Mar 2014 Link to this post

    I have this aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="SPAC.Web.Paginas.test" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                    </asp:ScriptReference>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                    </asp:ScriptReference>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                    </asp:ScriptReference>
                </Scripts>
            </telerik:RadScriptManager>
            <telerik:RadAjaxManager runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btn">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="lbl" UpdatePanelCssClass="" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
        <div>
            <telerik:RadAjaxPanel runat="server" HorizontalAlign="NotSet" ID="pnl">
                <asp:Button runat="server" Text="test" ID="btn" OnClick="btn_OnClick"/>
                <asp:Label runat="server" Text="test" ID="lbl"></asp:Label>
            </telerik:RadAjaxPanel>
        </div>
        </form>
    </body>
    </html>
     And my code behind is like:
    protected void btn_OnClick(object sender, EventArgs e)
            {
                lbl.Text = "nada";
            }

    When I click on the button, the label "lbl" disappears (it should change the text of the label). Should I use two panels? or how can I ajaxify the asp controls?

    Thanks in advance
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Mar 2014 in reply to RICARDO Link to this post

    Hi RICARDO,

    Please do the following modifications in your ASPX page and have a look into this help documentation.

    ASPX:
    ...       
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="btn">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="pnl" />
                        <telerik:AjaxUpdatedControl ControlID="lbl" UpdatePanelCssClass="" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
    </telerik:RadAjaxManager>
    ...

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RICARDO
    RICARDO avatar
    2 posts
    Member since:
    May 2012

    Posted 10 Mar 2014 Link to this post

    Hi Princy, thanks for the reply. In fact, your solution works but I've been testing with another scenario and got a behavior that I think it's kinda buggy:

    <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js">
                    </asp:ScriptReference>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js">
                    </asp:ScriptReference>
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js">
                    </asp:ScriptReference>
                </Scripts>
            </telerik:RadScriptManager>
            <telerik:RadAjaxManager runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btn">
                        <UpdatedControls>                       
                            <telerik:AjaxUpdatedControl ControlID="lbl" LoadingPanelID="ralMain"/>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="btn2">
                        <UpdatedControls>                       
                            <telerik:AjaxUpdatedControl ControlID="lbl2" LoadingPanelID="ralMain"/>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel runat="server" ID="ralMain"></telerik:RadAjaxLoadingPanel>
            <div>
                <telerik:RadAjaxPanel runat="server" HorizontalAlign="NotSet" ID="pnl">
                    <asp:Button runat="server" Text="test" ID="btn" OnClick="btn_OnClick"/>
                    <asp:Label runat="server" Text="test" ID="lbl"></asp:Label>
                    <asp:Button runat="server" Text="test2" ID="btn2" OnClick="btn2_OnClick"/>
                    <asp:Label runat="server" Text="test2" ID="lbl2"></asp:Label>
                </telerik:RadAjaxPanel>
            </div>
        </form>
     
    and my code behind:

    protected void Page_Load(object sender, EventArgs e)
            {
     
            }
     
            protected void btn_OnClick(object sender, EventArgs e)
            {
                System.Threading.Thread.Sleep(1000);
                lbl.Text = "this is lbl";
            }
     
            protected void btn2_OnClick(object sender, EventArgs e)
            {
                System.Threading.Thread.Sleep(1000);
                lbl2.Text = "this is lbl2";
            }

    When I click "btn" the label "lbl" diasppears as before. When I click "btn2", that label "lbl" appears with the text "this is lbl" and "lbl2" disappears. Is this an expected behavior? Or am I doing anything wrong?
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Mar 2014 in reply to RICARDO Link to this post

    Hi RICARDO,

    We highly recommend to avoid working with the RadAjaxManager & RadAjaxPanel controls at the same time. Use the controls depending on your exact scenario. Please try the following ASPX code which works fine at my end. 

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="btn">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnl" LoadingPanelID="ralMain" />
                    <telerik:AjaxUpdatedControl ControlID="lbl" LoadingPanelID="ralMain" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btn2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="pnl" LoadingPanelID="ralMain" />
                    <telerik:AjaxUpdatedControl ControlID="lbl2" LoadingPanelID="ralMain" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    Hope this will helps you.
    Thanks,
     Princy.
Back to Top