Visual Basic .NET » Web Forms
Add Ajax programmaticly -- LCIDFire --


I tried to build a test application for calling a server side method out of javascript but it just doesn't work. It seems to me it doesn't register the type for callback. I setup the web.config, like the quick sample, too.
Can anybody provide a simple example how to do this?

I tried the following:

namespace test
{
public partial class treelist : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HtmlImage image = new HtmlImage();
image.Src = "
http://www.golem.de/_img/logo_bottom.gif 
";
image.Attributes
= "test.treelist.Expand(4,
Expand_callback)";

ClientScript.RegisterClientScriptBlock(GetType(),
"expandcallback", "function Expand_callback(result){alert(result.value}}", true);
form1.Controls.Add(image);
Utility.RegisterTypeForAjax(GetType());
}


public String Expand(int recId)
{
return "blub";
}
}
}

-- Zihotki --


may be you should do so:
Utility.RegisterTypeForAjax(GetType(treelist));

-- LCIDFire --


Appearently I should have done Utility.RegisterTypeForAjax(typeof(treelist));

When I do the latter I get:
{Name = "treelist" FullName = "test.treelist"}

When I try my first approach I get:
{Name = "treelist_aspx" FullName = "ASP.treelist_aspx"}

WTF!?
Does one have to understand this? I was under the impression that the content of the aspx was "partialized" into the tree class not the other way around.

-- MichaelSchwarz --


If you use this.GetType() you will get the current instance which will be the ASPX page instead of the class treelist. ASP.NET will add a new class ASP.reelist_aspx for any ASPX inline code. If you use typeof(treelist) it will use the correct type. It is common ASP.NET logic, nothing to do with AjaxPro.

Regards,
Michael
On 7/12/06, LCID Fire <lcid-fire> wrote:

Appearently I should have done
Utility.RegisterTypeForAjax(typeof(treelist));

When I do the latter I get:
{Name = "treelist" FullName = "test.treelist"}

When I try my first approach I get:
{Name = "treelist_aspx" FullName = "ASP.treelist_aspx"}

WTF!?
Does one have to understand this? I was under the impression that the
content of the aspx was "partialized" into the tree class not the other
way around.
>

--  

Best regards | Schöne Grüße Michael

Microsoft MVP - Most Valuable Professional Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz 
/
http://www.schwarz-interactive.de 
/
mailto:info
[Submit Comment]Home