AJAX.NET Callback

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
 
P

PJ6

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

Paul
 
V

Varangian

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 ?
 
J

Jacob

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.
 
V

Varangian

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 ?
 
P

PJ6

You need to render some server-side script to get the values...

document.getElementById("RandomElement1").value

Paul
 
J

Jacob

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.
 
V

Varangian

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 ?
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top