AJAX.NET Callback

  • Thread starter Thread starter Varangian
  • Start date Start date
V

Varangian

Hi,

maybe there a couple of people working around with ASP.NET
Callbacks..... Callbacks are working fine i.e. a Button hit from the
client then makes server side work and then back again to the client
without any postbacks...

However when those values need to be used from the server side ... they
don't reflect the real value updated... my question is what needs to be
done to read a value from a control that has been updated by AJAX
callback ?

thanks
 
Give up with the standard event model, it's junk. Make your buttons AJAX,
too and you'll be all set.

Paul
 
what do you mean exactly ? yes almost I will do anything AJAX... but I
need to get values from those updated controls by AJAX... what are the
options ?
 
You have to access the control's values as you would with normal
clientside scripting. For example you would get a textbox's text using
the JavaScript command document.getElementById("textbox1").value;

The callback implementation in asp.net 2 doesn't allow you to use your
serverside script on the client, it only eases the setup of the
callback communication.
 
how can I do this? The GetCallBackEventReference already sets attribute
on a Button "OnClick" forexample ... how do I get back the value ? do I
need to override the "OnClick" attribute with another function ?
 
You need to render some server-side script to get the values...

document.getElementById("RandomElement1").value

Paul
 
You can either use the ClientClick property of the button or you can
add an ordinary HTML button and give it a click event handler on the
client.

It's difficult to know what you are trying to do since you don't post
any code or link.
 
ok then thanks first of all .. all of you :)

say I have this code on the Server Side

// On page set callbackreference
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("OnClick",
this.Page.ClientScript.GetCallbackEventReference(this, "'datetime'",
"DisplayDateTime", null) + "; return false;");
}

#region ICallbackEventHandler Members

string s_CallbackResult;

public string GetCallbackResult()
{
return s_CallbackResult;
}

public void RaiseCallbackEvent(string eventArgument)
{
if (eventArgument == "datetime")
s_CallBackResult = DateTime.Now.ToString();
}

#endregion


now on the client side

function DisplayDateTime(result, context)
{
var label = document.getElementById('Label1');

label.innerHTML = result;
}



Now I want to use that Datetime value displayed on Label1 .... when I
did this and tried to get that value simply Label1.Text was marked as
"Label1" or ""

thats it? how can I retrieve that value from the Label ?
 
Back
Top