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

inject XmlHttpPanel progarammatically?

1 Answer 67 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
zahi kramer
Top achievements
Rank 1
zahi kramer asked on 06 Feb 2010, 06:02 PM
hi.
I need to use XmlhttpPanel inside DotNetNuke (which is built via UserConrtol loaded to the page).
so i tried this attached application to inject the XmlHttpPanel programmatically to usercontrol and load it to the page
and i want to activate the panl on the client side via javascript.

please tell me what is wrong and how i can enable it in this scenario.
thanks.

zahi.

p.s.
i tried to attach zip file and i can't .
please give me some email to send it....
thanks.

p.s.
I changed the attached .zip file to .jpg  to be uploadable.
please change it back to .zip and extract the solution.
thanks.

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 09 Feb 2010, 01:29 PM
Hello Zahi,

You should create the RadXmlHttpPanel control in the Page_Init. Then you should attach an event handler to the ServiceRequest server-side event or set the WebMethodName and WebMethodPath in case you are using WebServices. Here is a sample project that shows how to dynamically create a RadXmlHttpPanel control:

.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">
<head id="Head1" runat="server">
    <title></title>
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
 
        <script type="text/javascript">
            function SetValue()
            {
                var panel = $find("RadXmlHttpPanel1");
                panel.set_value("test");
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <input value="Set Value" onclick="SetValue(); return false;" type="button" />
    <div>
    </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;
using Telerik.Web.UI;
 
public partial class Dynamic_XmlHttpPanel : System.Web.UI.Page
{
    protected void Page_Init(object sender, EventArgs e)
    {
        RadXmlHttpPanel xmlPanel = new RadXmlHttpPanel();
        xmlPanel.ID = "RadXmlHttpPanel1";
        xmlPanel.EnableClientScriptEvaluation = true;
        xmlPanel.ServiceRequest += new XmlHttpPanelEventHandler(xmlPanel_ServiceRequest);
        xmlPanel.WebMethodName = "";
        xmlPanel.WebMethodPath = "";
        form1.Controls.Add(xmlPanel);
    }
 
    protected void xmlPanel_ServiceRequest(object sender, RadXmlHttpPanelEventArgs e)
    {
        Label lbl = new Label();
        lbl.ID = "Label1";
        lbl.Text = DateTime.Now.ToString();
        RadXmlHttpPanel panel = (RadXmlHttpPanel)sender;
        panel.Controls.Add(lbl);
    }
}



Regards,
Pero
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
XmlHttpPanel
Asked by
zahi kramer
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or