Ajax Request doesn't Update Controlls

7 posts, 0 answers
  1. Thomas
    Thomas avatar
    14 posts
    Member since:
    Feb 2014

    Posted 11 Mar 2014 Link to this post

    Hi there,
    I want to fill a Hidden Field on an aspx page after clicking a link.

    My Code:
    01.<%@ Page Title="Home Page" Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication6._Default" %>
    02.<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    03. 
    04.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    05.<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    06.<head id="Head1" runat="server">
    07.    <title></title>
    08.</head>
    09.<body>
    10.    <form id="Form1" runat="server">
    11.    
    12.        <telerik:RadAjaxManager ID="RadAjaxManagerCopyLink" runat="server">       
    13.            <AjaxSettings>
    14.                <telerik:AjaxSetting AjaxControlID="RadAjaxManagerCopyLink">
    15.                    <UpdatedControls>
    16.                        <telerik:AjaxUpdatedControl ControlID="Hidden_LayoutID" />                   
    17.                    </UpdatedControls>               
    18.                </telerik:AjaxSetting>
    19.            </AjaxSettings>
    20.            <ClientEvents OnResponseEnd="responseEndCopyLink" />
    21.        </telerik:RadAjaxManager>
    22.     
    23.        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    24.            <script type="text/javascript">
    25.                function CopyLink()
    26.                {
    27.                    $find("<%= RadAjaxManagerCopyLink.ClientID %>").ajaxRequest("TeST");
    28.                }
    29. 
    30.                function responseEndCopyLink(sender, eventArgs)
    31.                {
    32.                    alert('<' + document.getElementById("<%=Hidden_LayoutID.ClientID %>").value + '>');
    33.                }
    34.            </script>
    35.        </telerik:RadCodeBlock>
    36.        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
    37.         
    38.        <input type="hidden" id="Hidden_LayoutID" name="Hidden_LayoutID" runat="server" />
    39. 
    40.        <a id="Link1" runat="server" href="javascript:CopyLink();"> Create Layout Link  </a><br />       
    41.    </form>
    42.</body>
    43.</html>

    1.Public Class _Default
    2.    Inherits System.Web.UI.Page
    3. 
    4.    Private Sub RadAjaxManager1_AjaxRequest(sender As Object, e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManagerCopyLink.AjaxRequest
    5.        Hidden_LayoutID.Value = "Hallo " & e.Argument.ToString
    6.    End Sub
    7.End Class

    All work fine, but the VB.Net code doesn't change the Hidden_LayoutID.

    What went wrong?

    Thanks for answers
    Thomas
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Mar 2014 in reply to Thomas Link to this post

    Hi Thomas,

    Please try to attach the OnAjaxRequest event of RadAjaxManager in ASPX or code behind. Please do the following modifications in your code which works fine at my end.

    ASPX:
    <telerik:RadAjaxManager ID="RadAjaxManagerCopyLink" runat="server" OnAjaxRequest="RadAjaxManagerCopyLink_AjaxRequest">
               ...
    </telerik:RadAjaxManager>

    C#:
    Protected Sub RadAjaxManagerCopyLink_AjaxRequest(sender As Object, e As Telerik.Web.UI.AjaxRequestEventArgs)
        Hidden_LayoutID.Value = "Hallo " & e.Argument.ToString
    End Sub

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Thomas
    Thomas avatar
    14 posts
    Member since:
    Feb 2014

    Posted 13 Mar 2014 in reply to Shinu Link to this post

    Hi Shinu,
    same result with your changes :(

    the Breakpoint in
    RadAjaxManagerCopyLink_AjaxRequest is triggered, but the Hidde_LayouID field is still empty on the clientside

    Regards
    Thomas

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Mar 2014 in reply to Thomas Link to this post

    Hi Thomas,

    Unfortunately I couldn't replicate the issue at my end. Please take a look into this sample project. Let me know whether this sample project is working or not.

    Thanks,
    Shinu.
  6. Thomas
    Thomas avatar
    14 posts
    Member since:
    Feb 2014

    Posted 14 Mar 2014 Link to this post

    Hi Shinu,
    your sample project working fine. You use the "asp:ScriptManager" instead of the "telerik:RadScriptManager". If I change this in my project its working too. But in my main project I cannot change to the asp-Scriptmanager (javascript-assert in Microsoft AJAX Framework: "Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'String'").

    Is there another way with the telerik-Scriptmanager?

    Regards
    Thomas
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Mar 2014 in reply to Thomas Link to this post

    Hi Thomas,

    I changed the 'asp:ScriptManager' to 'telerik:RadScriptManager' and the provided solution is working fine at my end. I am not getting any kind of error from the provided code.

    Thanks,
    Shinu.

  8. Thomas
    Thomas avatar
    14 posts
    Member since:
    Feb 2014

    Posted 14 Mar 2014 Link to this post

    OK, Issue found: The RadScriptManager was at the end of the page...

    Thanks a lot for helping :)
    Thomas
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017