I found this AJAX .NET framework the other day, and so far I am enjoying working with it. However, one thing I can't figure out (the documentation is rather poor atm) is how to pass variables through the AJAX script. This is what I have so far:
//default2.aspx.vb
<AjaxPro.AjaxMethod()> _
Public Shared Function testSomething(ByVal value As String) As String
Return value
End Function
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AjaxPro.Utility.RegisterTypeForAjax(GetType(Default2))
End Sub
//default2.aspx
<a href="#" onclick="doTest(1);">test something</a>
<div id="temp" style="margin:15px 15px 0px 5px; padding:10px;"></div>
<script type="text/javascript">
function doTest(x){
Default2.testSomething(doTest_callback,x)
}
function doTest_callback(res,x){
alert(res.value);
document.getElementById("temp").innerHTML = ">>>> " + x + " <<<<"
}
</script>
I have a couple of other test functions that work fine, and they do comparatively more complex operations. Anyone have any insight into how to pass variables with AjaxPro? Alternative methods are welcome as well!
It's been a while since I used that framework (version 6.9.22.2, so things may have changed a little) - have you had a look at the ASP.NET AJAX framework? I'm not sure how much work Michael's done on this since that came out - certianly his blog posts about it dried up around July 2007.
Anyway, if I understand your question right, you want to:
Firstly, to pass variables to your methods, shouldn't they come before the name of the callback function?
To retrieve the initial values in the callback, I either:
Going with option 2, you'd have:
The main downside with this, is that if the user fires your "doTest" method with a different value while you're still processing the first request, the value of initialValue could well have changed by the time it's queried in doTest_callback.