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

Ajax Request doesn't Update Controlls

6 Answers 49 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 11 Mar 2014, 05:20 PM
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

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Mar 2014, 02:51 AM
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.
0
Thomas
Top achievements
Rank 1
answered on 13 Mar 2014, 10:49 AM

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

0
Shinu
Top achievements
Rank 2
answered on 14 Mar 2014, 06:38 AM
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.
0
Thomas
Top achievements
Rank 1
answered on 14 Mar 2014, 09:18 AM
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
0
Shinu
Top achievements
Rank 2
answered on 14 Mar 2014, 09:54 AM
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.

0
Thomas
Top achievements
Rank 1
answered on 14 Mar 2014, 11:48 AM
OK, Issue found: The RadScriptManager was at the end of the page...

Thanks a lot for helping :)
Thomas
Tags
Ajax
Asked by
Thomas
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Thomas
Top achievements
Rank 1
Share this question
or