ClientSide Binding Using Ajax page Method

Last post 05-09-2008 9:45 AM by NC01. 4 replies.

Sort Posts:

  • ClientSide Binding Using Ajax page Method

    05-08-2008, 11:38 AM
    • Loading...
    • Saran_Bkvel
    • Joined on 05-07-2008, 4:37 PM
    • Posts 3

    Dear All,

    Iam using Asp.Net Ajax PageMethod for loading a UserControl Dynamically.But If i use any AjaxToolKit Control in the user Control iam Getting the following error:

    Error executing child request for handler 'System.Web.UI.Page'

    My Software Specification is

    VS2008(Microsoft Visual Web Developer 2008),Dotnet Framework 3.5,AjaxToolkit 2.0

     

    Any solution for this issue will be thankfull a lot

     

    Thanks in advance,

    Regards,

    Saravanan K

  • Re: ClientSide Binding Using Ajax page Method

    05-08-2008, 1:02 PM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 6,886
    • TrustedFriends-MVPs

    Post the code causing the error.

    NC...

     

  • Re: ClientSide Binding Using Ajax page Method

    05-09-2008, 4:02 AM
    • Loading...
    • Saran_Bkvel
    • Joined on 05-07-2008, 4:37 PM
    • Posts 3

    Hi Thanks for ur response...

    I put my entire application code below With ajax tool kit control

    <ajaxToolkit:CascadingDropDown id="BL1" runat="server"></ajaxToolkit:CascadingDropDown>

    in TestControl.ascx file it shows the following error

    Error executing child request for handler 'System.Web.UI.Page'

    without that ajax control it works fine calls the method and loads usercontrol and it displays current date and time...

    Pls provide me a solution for this issue....

    Thanks in advance...

    Regards

    Saravanan K

     

     

     

    My WebMethods aspx page

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebMethods.aspx.cs" Inherits="_WebMethods" %>

    <%@ Import Namespace="System.Web.Services"%>

    <%@ Register Src="UCTestemunhos.ascx" TagName="UCTestemunhos" TagPrefix="uc1" %>

     

     

    <!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>Test PageMethods</title>

    </head>

    <body>

    <form id="form1" runat="server">

    <asp:ScriptManager ID="manager" runat="server" EnablePageMethods="True">

    </asp:ScriptManager>

    <div>

    <uc1:UCTestemunhos ID="UCTestemunhos1" runat="server" />

    </div>

    <div id="divtable" runat="server">

     

    </div>

    </form>

    </body>

    </html>

    My WebMethods.aspx.cs page

    using System;

    using System.Data;

    using System.Configuration;

    using System.Collections;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using System.Web.Services;

    using System.Web.Mail;

    using System.IO;

    using System.Text;

     

     

    public partial class _WebMethods : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

     

    }

    [System.Web.Services.
    WebMethod]public static string SendForm(string name)

    {

    if (string.IsNullOrEmpty(name))

    {

    Page pageHolder = new Page();

    Control ctrl = (UserControl)pageHolder.LoadControl("TestControl.ascx");

    //Control CTRL = new TestControl();

     

    pageHolder.Controls.Add(ctrl);

    //StringBuilder sb = new StringBuilder();

    //StringWriter sw = new StringWriter(sb);

    //HtmlTextWriter htw = new HtmlTextWriter(sw);

    //CTRL.RenderControl(htw);

    //ctrl.RenderControl(htw);

    //pageHolder.RenderControl(htw);

    StringWriter output = new StringWriter();

    HttpContext.Current.Server.Execute(pageHolder, output, false);

    return output.ToString();

    //return sb.ToString();

    //throw new Exception("Enter name.");

    }

    return "";

     

    }

     

     

    }

    My Usercontrol  UCTestemunhos.ascx for webmethods page .ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="UCTestemunhos.ascx.cs" Inherits="UCTestemunhos" %>

    <asp:ScriptManagerProxy ID="sm1" runat="server">

    <Scripts>

    <asp:ScriptReference Path="~/Scripts.js" />

    </Scripts>

    </asp:ScriptManagerProxy>

    <fieldset id="ContactFieldset">

    <button id="Binding" onclick="SendForm();">Client Side Binding</button>

    </fieldset>

    using System;

    using System.Collections;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    public partial class UCTestemunhos : System.Web.UI.UserControl

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    }

     

    }

     

    My TestControl.ascx file

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestControl.ascx.cs" Inherits="TestControl" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

    <hr />

    Hello <asp:Label id="worldText" runat="server" />

    <asp:Label id="dateTime" runat="server"></asp:Label>

    <ajaxToolkit:CascadingDropDown id="BL1" runat="server"></ajaxToolkit:CascadingDropDown>

    <hr />

    TestControl.ascx.cs

    using System;

    using System.Collections;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    public partial class TestControl : System.Web.UI.UserControl

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    worldText.Text =
    "world!";dateTime.Text = DateTime.Now.ToString();

    }

    }

  • Re: ClientSide Binding Using Ajax page Method

    05-09-2008, 4:12 AM
    • Loading...
    • Saran_Bkvel
    • Joined on 05-07-2008, 4:37 PM
    • Posts 3

    I Missed the Scripts.js file // "Scripts.js" function SendForm() { var name = ""; PageMethods.SendForm(name, OnSucceeded, OnFailed); } function OnSucceeded(result) { //$get("ContactFieldset").innerHTML = result; //$get("divtable").innerHTML= result; var divInfo = document.getElementById("divtable"); divInfo.innerHTML = result; } function OnFailed(error) { // Alert user to the error. alert(error.get_message()); }

  • Re: ClientSide Binding Using Ajax page Method

    05-09-2008, 9:45 AM
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 6,886
    • TrustedFriends-MVPs

    Sorry, far too much code to read through. Just don't have that much free time. Only the code causing the problem is necessary.

    NC...

Page 1 of 1 (5 items)