Claus Pedersen
Top achievements
Rank 1
Claus Pedersen
asked on 25 Mar 2010, 09:30 AM
The scenario using version 2010_1_309:
)
I have a left pane with various controls that are used to filter the result of the main pane.
The main pane has a XmlHttpPanel with a ListView inside.
When I have chosen the values in my filter pane and click a "filter" button, it calls this javascript:
function search(sender, args) { |
var panel = $find("<%=RadXmlHttpPanelProperties.ClientID %>"); |
panel.set_value(''); |
return false; |
} |
(By the way, I can't call "set_value()" without a parameter - that cause a javascript error in Telerik javascript files
this.get_value() is undefined |
[Break on this error] },_getCallbackArgument:function(){var b=this.get_value().replace(/"/g,'\\"'); |
That initiates the xmlHttpPanel_ServiceRequest as it should.
But I can't read the values of my page controls from within that service request, shouldn't I be able to do that?
If the page has "Viewstate=false" then the selected value of a DropdownBox is empty, if the page viewstate is one, then the selected value is always the default value.
If the page has "Viewstate=false" then the selected value of a DropdownBox is empty, if the page viewstate is one, then the selected value is always the default value.
Thanks
Claus
7 Answers, 1 is accepted
0
Hello Claus,
Please test the following code. You will notice that the value is sent correctly to the server:
.cs
Notice that I am using double quotes when setting the panel's value.
If you still have problems, please send the full source code of your project (or sample project), so we are able to reproduce the problem locally.
Sincerely yours,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Please test the following code. You will notice that the value is sent correctly to the server:
<%@ 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
id
=
"Head1"
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function SetValue()
{
var panel = $find("<%=XmlPanel1.ClientID %>");
panel.set_value("Value set by callback: ");
}
</
script
>
</
telerik:RadScriptBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
</
Scripts
>
</
asp:ScriptManager
>
<
input
value
=
"Set Value (callback)"
onclick
=
"SetValue(); return false;"
type
=
"button"
/>
<
div
>
<
telerik:RadXmlHttpPanel
ID
=
"XmlPanel1"
runat
=
"server"
OnServiceRequest
=
"XmlPanel1_ServiceRequest"
EnableClientScriptEvaluation
=
"true"
>
<
asp:Literal
ID
=
"Literal1"
runat
=
"server"
></
asp:Literal
>
<
br
/>
<
br
/>
<
asp:Literal
ID
=
"Literal2"
runat
=
"server"
></
asp:Literal
>
</
telerik:RadXmlHttpPanel
>
</
div
>
</
form
>
</
body
>
</
html
>
.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
XmlPanel_Lifecycle : System.Web.UI.Page
{
protected
void
XmlPanel1_ServiceRequest(
object
sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
{
Literal1.Text = e.Value + DateTime.Now.ToString();
}
}
Notice that I am using double quotes when setting the panel's value.
If you still have problems, please send the full source code of your project (or sample project), so we are able to reproduce the problem locally.
Sincerely yours,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Claus Pedersen
Top achievements
Rank 1
answered on 30 Mar 2010, 01:37 PM
Hello Pero,
The problem is that my filter pane contains a lot of controls (some dynamically generated), which I need access to from my service request. It is not enough that I just have access to the single control that was changed.
I was hoping for a simple solution for sending as little data as possible back and forth between the server and the client. JSON data would have been preferred, but XML is ok.
Kind regards
Claus Pedersen
0
Hi Claus,
You could send JSON data (available in the latest version of the RadControls for the ASP.NET AJAX) from the client to the server, as shown in the following example:
.aspx
.cs
All the best,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You could send JSON data (available in the latest version of the RadControls for the ASP.NET AJAX) from the client to the server, as shown in the following example:
.aspx
<%@ 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
id
=
"Head1"
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function SetValue()
{
var panel = $find("<%=XmlPanel1.ClientID %>");
var stringArray = [];
stringArray[0] = "Value1";
stringArray[1] = "Value2";
stringArray[2] = "Value3";
Sys.Serialization.JavaScriptSerializer.serialize(stringArray);
panel.set_value(Sys.Serialization.JavaScriptSerializer.serialize(stringArray));
}
</
script
>
</
telerik:RadScriptBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
</
Scripts
>
</
asp:ScriptManager
>
<
asp:Button
ID
=
"Button2"
runat
=
"server"
Text
=
"Postback"
/>
<
input
value
=
"Set Value (callback)"
onclick
=
"SetValue(); return false;"
type
=
"button"
/>
<
div
>
<
telerik:RadXmlHttpPanel
ID
=
"XmlPanel1"
runat
=
"server"
OnServiceRequest
=
"XmlPanel1_ServiceRequest"
EnableClientScriptEvaluation
=
"true"
>
<
asp:Literal
ID
=
"Literal1"
runat
=
"server"
></
asp:Literal
>
<
br
/>
<
br
/>
<
asp:Literal
ID
=
"Literal2"
runat
=
"server"
></
asp:Literal
>
</
telerik:RadXmlHttpPanel
>
</
div
>
</
form
>
</
body
>
</
html
>
.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public
partial
class
Send_JSON : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
XmlPanel1_ServiceRequest(
object
sender, Telerik.Web.UI.RadXmlHttpPanelEventArgs e)
{
System.Web.Script.Serialization.JavaScriptSerializer serializer =
new
System.Web.Script.Serialization.JavaScriptSerializer();
string
[] strArray = serializer.Deserialize<
string
[]>(e.Value);
foreach
(
string
s
in
strArray)
Literal1.Text += s +
" | "
;
}
}
All the best,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Claus Pedersen
Top achievements
Rank 1
answered on 31 Mar 2010, 01:07 PM
Hello Pero,
Thank you.
The amount of data from client to server isn't a problem and it would be easier if I had direct access to control values instead of passing them through set_value which is a bit time consuming and not very easy to maintain.
Data sent from server to the client would be great if that could be JSON and only sending the data, not the markup.
A search result like this, often consist of a long list of similar items (markup wise), so it is a waste of bandwidth and time to send the markup to the client for each item.
Kind regards
Claus
0
Hi Claus,
You can initiate partial page updates, with the XmlHttpPanel, using the set_value() method, and passing a string value to the panel. This is the only way to send and control the values send to the server.
The data sent from the server to the client is the HTML markup that will be pasted within the panel. We don't have any workarounds to modify the content, to be in JSON format.
Greetings,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
You can initiate partial page updates, with the XmlHttpPanel, using the set_value() method, and passing a string value to the panel. This is the only way to send and control the values send to the server.
The data sent from the server to the client is the HTML markup that will be pasted within the panel. We don't have any workarounds to modify the content, to be in JSON format.
Greetings,
Pero
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jack
Top achievements
Rank 1
answered on 28 May 2012, 05:03 PM
It seems to be some changes in latest version of xmlHttpCallback.
Following code is not executed if Value in telerik:RadXmlHttpPanel control is not set:
protected void RadXmlHttpPanelInfoCustomer_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)
{
LoadData(e.Value);
//This on loads data and update a Repeater control
}
If I hard code “Value” of that control in ASPX I am not able to change “Value” from java script.
<telerik:RadXmlHttpPanel
ID="rxhpProdShow"
runat="server"
Value="Hardcoded value" OnServiceRequest="XmlHttpPanel_ServiceRequest"
RenderMode="Block">
In my js file I call OnPanProductsClientClicked from another control with different values in args
function OnPanProductsClientClicked(sender, args) {
var panel1 = $find("rxhpProdShow");
var item = args.get_item();
strKey = item.get_text();
panel1.set_value(strKey);
//if I check the value here is all fine
//alert("value) - " + panel1.get_value());
}
But on server side I get hardcoded value from ASPX page.
0
Hello Jack,
I tried to reproduce the behavior you described with the latest release, but to no avail. Which version of RadControls for ASP.NET AJAX are you currently using? I have attached my test page, so that you can compare it with your actual project and check if there are differences in the setup. As shown in this screen capture, the ServiceRequest event handler is executed event if no value is passed to the RadXmlHttpPanel. Also, the value specified in the property Value of the control, is applied only on page load. It is changed when a new value is set via the client-side method set_value of RadXmlHttpPanel.
I would suggest updating to the latest release of RadControls for ASP.NET AJAX and verifying if the examined behavior persists.
If you are still having difficulties, please describe the changes that should be made to the attachment so that the problem is reproducible. This will allow me to inspect this behavior locally and provide a more to the point answer.
Greetings,
Slav
the Telerik team
I tried to reproduce the behavior you described with the latest release, but to no avail. Which version of RadControls for ASP.NET AJAX are you currently using? I have attached my test page, so that you can compare it with your actual project and check if there are differences in the setup. As shown in this screen capture, the ServiceRequest event handler is executed event if no value is passed to the RadXmlHttpPanel. Also, the value specified in the property Value of the control, is applied only on page load. It is changed when a new value is set via the client-side method set_value of RadXmlHttpPanel.
I would suggest updating to the latest release of RadControls for ASP.NET AJAX and verifying if the examined behavior persists.
If you are still having difficulties, please describe the changes that should be made to the attachment so that the problem is reproducible. This will allow me to inspect this behavior locally and provide a more to the point answer.
Greetings,
Slav
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.