Ajax Control Implementation Problem

M

madani

Hi,

I'm trying to make some ajax controls, I checked different ajax
controls to find out how they works.

main problem in developing ajax controls is updating other controls in
events that occur in ajax calls.

my controls use .NET 2.0 ICallBackEventHandler Internally and present
some Methods that occur in some Ajax Call.

As a very simple example, I made Button control that have Ajax OnClick
Method, I call this method in my RaiseCallbackEvent. Assume that user
change text of one text box in this Ajax OnClick Method. What I need to
do is find changes, and send them to client side, and then apply them
by JavaScript routines of my ajax control.

I checked different controls to check:

(1) How they find changes in other controls in ajax methods
(2) How they send changes to client.
(3) How they apply changes in client

First I checked zumiPage Controls
(http://www.zumipage.com/tutorial1.htm)

What it does to find out which control is changed is simple, it force
user to add changed controls to a collection.

Here is Sample:

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text += "1";
ReturnControls.Add(TextBox1);
}

to send changes to client and applying them, the easiest way is to
render changed control individually. then in most controls you can
change the whole control by set its outerHtml property to returned
rendered control. But the problem is

(4) how to render controls individually.

zumipage solved this problem this way:

it force you to inherit your page from zumiControls.zumiPage, So it can
handle render of controls and get rendered html of controls that it
need.

Here is sample:

public partial class MyPage : zumiControls.zumiPage
{
...

Adding controls to a collection is not a good idea; user should always
remember to add changed controls to ReturnedControls Collection. it's
much better that Ajax control find changes by itself.

Other Ajax Control that I checked was MagicAjax
(http://www.magicajax.net/)

It's idea is really nice.

It use an http module, you should add it to you WebConfig, it will
store an instance of controls on server and use hash to find out which
control is changes(1). This control is free and open source, and using
it is very easy, it can add Ajax Functionality to existing standard
Asp.net controls. All you need to add ajax functionality is too add
your controls to a MagixAjax AjaxPanel. it will handle the rest by
itself.

this control also render changed controls individually. it not big
problem, because changed controls must be inside it's AjaxPanel
control(4), and send the html of rendered control to client and apply
them by JavaScript (2 and 3).

here is simple example of this control :


<ajax:ajaxpanel ID="Ajaxpanel1" runat="server">
<asp:TextBox ID="txtSampleText"
runat="server"></asp:TextBox>
<asp:Button ID="cmdTest" Text="Test" runat="server"
OnClick="cmdTest_Click" />
</ajax:ajaxpanel>

And we have this in code behind:

protected void cmdTest_Click(object sender, EventArgs e)
{
txtSampleText.Text = "Text is Changed";
}

Now when you Click on cmdTest button, it use AjaxCall and text of
txtSampleText will change.

It's very nice idea, but it's not what I need. I want to add Ajax
Callback to my own controls.

So I checked the third Control, it's Telerik CallBack Control (
http://www.telerik.com/Default.aspx?PageId=2527 )

What these controls are doing it's exactly same as what I'm trying to
do.

They developed set of controls like button, and give most of client
side events as a Server Side Ajax Method of their controls.

Here is simple example:

<asp:TextBox ID="txtSampleText" runat="server"></asp:TextBox>
<cc1:callbackbutton id="cmdTest" Text="Test" OnClick="cmdTest_Click"
runat="server" />

What we have in code behind is:

protected void cmdTest_Click(object sender, EventArgs e)
{
txtSampleText.Text = "It's Changed";
}

As you see there is no need to add changed controls to a collection or
inherit page from customized page class.

I could not find out how it can find out which control is changed. And
how it get html of changed controls. it shows that it's possible, but
what I need to know is how?

-madani
 
M

madani

Actually the problem is:

1. How to find changes in other controls in an ajax method, without
asking user to add changed controls into a collection.
2. How to get HTML of changed controls, or how to render them
individually.

Regards
-madani
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top