ラベル returning の投稿を表示しています。 すべての投稿を表示
ラベル returning の投稿を表示しています。 すべての投稿を表示

2012年3月26日月曜日

Response.Redirect not working in RC version

I am trying to use Response.Redirect in the RC version of AJAX but it is returning an error. I have found a similar post to this issue and it discusses Beta2 vs RC references. I have ensured that all of my references are pointing to the System.Web.Extensions for the RC release yet the problem still exists.

Any ideas as to how I can fix this issue? Sorry if this is repeated, I just didn't find a clear response in the other posts.

But, what's the error? Can you post it?

The error is:

Sys.WebForms.PageRequestManagerParserException: The message received from the server could not be parsed... Error parsing near '<!DOCTYPE html PUB'

My code basically performs a Response.Redirect to another page in the site when a certain condition is met. I am using the AJAX Update Panel and various button control triggers that are all working fine.


You can't place Redirect in partial postback.

PageRequestManagerParserException waits for data from UpdatePanels (for example in JSON format, but I'm not sure), but you Redirect gives another data. In you case it like that redirect doing at server and PageRequestManagerParserException gets new page.

You must do redirect with some javascripts.

You have 2 ways:

1) use my evalscripts.js (it extends UpdatePanels, that it can evaluate javascripts, so you can put window.open('xxxyyy.aspx','_top') in some Literal in Label, and it works)

2) use ScriptManager.RegisterClientScript static method. On this forum is very many messages about it. Try to search. (and yes, you also do it throught javascript's window.open)

And of course try to read documentation. Maybe something changed in RC1 and there are some new methods for redirect. I don't know.


Something at you end is not set up well. Check this to make sure everything checks uphttp://ajax.alpascual.com/Walkthrough/AtlasToAspNetAjax.aspx

jriell:

Thanks for the feedback. Where can I obtain your evalscripts.js?

You can download all this from http://ajax.asp.net


Thanks for the feedback. Where can I obtain your evalscripts.js?

Thank You.

As a followup on the problem I had. I did omit something from the web.config of my site. After adding this element to the web.config, the Response.Redirect code that I have started working. It seems as though this functionality does work in the RC version at least.


jriell:

Thank You.

As a followup on the problem I had. I did omit something from the web.config of my site. After adding this element to the web.config, the Response.Redirect code that I have started working. It seems as though this functionality does work in the RC version at least.

Can you say what you add to web.config? Just interesting.

ps. this is work in RC1 ?


albertpascual:

jriell:

Thanks for the feedback. Where can I obtain your evalscripts.js?

You can download all this from http://ajax.asp.net

this is my own script, and there are now way to obtain it from ajax.asp.net , it can be found athttp://forums.asp.net/thread/1465522.aspx

Retrieve JSON result set

What is the best method for retrieving a result set and returning a JSON object? I tried using a DataSet, but received a serialization error.

TIA

You do not have to do anything special to convert in JSON. The Asp.net Ajax Automatically handles it. But in case you want to some manual proessing use the JavaScriptSerializer.


You do not have to do anything special to convert in JSON. The Asp.net Ajax Automatically handles it. But in case you want to some manual proessing use the JavaScriptSerializer. The DataSet is not supported with the Current Version, Add the January CTP to work with DataSet and DataTable.


I am a little confused. Can you provide an example of how to retrieve a JSON serialized result set? Where do I find the January CTP?

TIA


You can find the January CTP from this linkhttp://www.microsoft.com/downloads/details.aspx?familyid=4CB52EA3-9548-4064-8137-09B96AF97617&displaylang=en

return a html table with ajax C#

hi

I am writing a website using C#, web services and ajax. I have my ajax web service call returning either an array or a DataTable object. Does anyone have any example of writing either one of these returned values to a html table using javascript?

thanks

C

It might help http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

2012年3月24日土曜日

Returning a Collection when calling a Webservice from the Client

Hi everybody.

I want to return some kind of collection of objects when calling a Webservice from the Client
I saw a couple of tutorials and how to's how to return a complex type in this situation.

What i did not find is information how to pass a list of objects back to javascript.
i tried returning an array of string or a generic list of string, but then i can't process it on ClientSide.
Maybe i declare my callback function wrongly in javascript.

Does anybody have samples for this or any input?

Thanks! Martin

Hi Martin,

I'am returning some object arrays from server to JS, and processing this in client-side, here some pseudo:

Server Side:

[WebMethod]public MyObject[] GetMyObjectArray(){//...some fancy codereturn(myObjectArray);}Client-Side//The CallMyNameSpace.GetMyObjectArray(Process_OnComplete, onTimeout);function Process_OnComplete(result){for(var i=0; i < result.length; i++){
alert(result[i].MyObjectProperty);
 }

}

hope this help


Hello kpeguero!
Thx a lot for your reply!

Seems i was just a victim of Caching.
But your sample helped me to be sure that i'm on the right way with my attempts. ;)

It works fine now wether i'm using arrays or generics... cool :)

Regards Martin

Returning a dataset from a web service

Say I have a page that calls a web service from a client function to get some data to bind a gridView like this:

-------------------

<scripttype="text/javascript"language="JavaScript">

function GetDataSet(){

var ds = SimpleService.ActiveProcess();

}

</script >

-------------------

And the web service looks something like this:

-------------------

[WebMethod]

public datasetActiveProcess(){

string connectionString ="Connstring stuff here";

DataSet ds = csql.GetActiveProcess(connectionString);

return ds;

}

-------------------

Of course, because I'm posting this problem, this isn't the correct way to implement this kind of solution...

Question is: Is there a better way? Or how do I manage to handle and display what's being returned from this web service in the web page?

thanks.

doug

This issue is associated with an Atlas Web Service call.

Here is a crude solution that I still need to refine:

------------------------

1. JavasScript call to webservice:

------------------------

function fnSetTimeout( ){

//this is the call to the web service.

var ds = SimpleService.ActiveProcess(OnComplete, OnTimeout);

}

------------------------

2. Webservice method

------------------------

[WebMethod]

publicstring ActiveProcess(){

string connectionString ="Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=simple2;Data Source=local

string xmlReader = csql.GetActiveProcess(connectionString);

return xmlReader;

}

------------------------

3 Webservice method

------------------------

publicstring GetActiveProcess(string connString)

{

string strSQL ="Select id, threadid, conversationId from ActiveProcess";

SqlConnection conn =newSqlConnection(connString);

SqlDataAdapter da =newSqlDataAdapter(strSQL, conn);

DataSet ds =newDataSet();

try

{

conn.Open();

da.Fill(ds);

XmlDataDocument xmlDataDocument =newXmlDataDocument(ds);

return xmlDataDocument.OuterXml.ToString();

}

catch (SqlException ex)

{

returnnull;

}

}

------------------------

3 Load the XML into parser

------------------------

/*==============================================================================

function: OnComplete

paramaters: result

Purpose: Gets the results from the ATLAS call and parses into an XML document

Date: 12/21/2005

==============================================================================*/

function OnComplete(result)

{

//Load XML

var XMLDoc =new ActiveXObject("Microsoft.XMLDOM");

try

{

XMLDoc.loadXML(result);

}

catch(err)

{

alert(err.description);

}

//Load XSL

var XSLDoc =new ActiveXObject("Microsoft.XMLDOM");

try

{

XSLDoc.async =false;

XSLDoc.load("ActiveRecords.xsl");

}

catch(err)

{

alert(err.description);

}

//Write the results of the transformation out to the div.

document.all.divTable.innerHTML = XMLDoc.transformNode(XSLDoc);

}

Here's the XSL if you're interested:

<?xmlversion="1.0"encoding="utf-8"?>

<xsl:stylesheetversion="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:templatematch="/">

<html>

<head>

<title>Active</title>

<style>

copy { font-family: Arial, Verdana;}

h1 { font-family: Arial, Verdana; font-size: 14pt;}

p { font-family: Arial, Verdana; font-size: 10pt;}

</style>

</head>

<body>

<p><fontface="verdana">Active</font></p>

<tableborder="1">

<tr>

<thclass="copy">ID</th>

<thclass="copy">Thread Id</th>

<thclass="copy">Configuration ID</th>

</tr>

<xsl:for-eachselect ="NewDataSet/Table">

<tr>

<td>

<xsl:value-ofselect="id"/>

</td>

<td>

<xsl:value-ofselect="threadid"/>

</td>

<td>

<xsl:value-ofselect="conversationId"/>

</td>

</tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

thanks...

Returning a dataset

I am using the Atlas bits that run on the RC build. I thought that there was the capability to return a dataset. Is that working at this point? I am getting a strange error where the local WebDev.WebServer.exe is generating an error and then exiting when I attempt to call a webservice that returns a dataset. The code is pretty simple, so I have included it here just incase I am doing something stupid. I am able to step thru my code, I exit from the method, and then bang I get the error on the terminal. Thoughts? Do I need to change what I am doing? Did I just make up the thought that Datasets were working at this point?
Wally

[WebMethod]

public System.Data.DataSet ReturnDataSet()

{

DataSet ds =newDataSet();

DataTable dt =newDataTable();

DataRow dr;

dt.Columns.Add(newDataColumn("tblStateId", System.Type.GetType("System.Int32")));

dt.Columns.Add(newDataColumn("State", System.Type.GetType("System.String")));

dr = dt.NewRow();

dr["tblStateId"] = 1;

dr["State"] ="Tennessee";

dt.Rows.Add(dr);

dr = dt.NewRow();

dr["tblStateId"] = 2;

dr["State"] ="Alabama";

dt.Rows.Add(dr);

ds.Tables.Add(dt);

return (ds);

}

Interesting. This looks like a bug in Atlas. When I try your code, I get a StackOverflow exception in the serialization process.

Yes, the StackOverflow Exception is what I got also. Sorry fornot being descriptive enough last night. I was a little tired andI am getting the flu. Sad [:(]

I suspect a bug in the DataSetConverter, which is probably caused by circular references between the DataSet and its DataTables.
What you could do for now is to return a DataTable instead (and not use a DataSet at all).

publicoverridestring Serialize(object o)
{
if (!(ois DataSet))
{
thrownew ArgumentException();
}
DataSet set1= (DataSet) o;
StringBuilder builder1=new StringBuilder();
builder1.Append('[');
bool flag1=true;
IEnumerator enumerator1= set1.Tables.GetEnumerator();
try
{
while (enumerator1.MoveNext())
{
DataTable table1= (DataTable) enumerator1.Current;
if (!flag1)
{
builder1.Append(',');
}
builder1.Append(JavaScriptObjectSerializer.Serialize(set1));
flag1=false;
}
}
finally
{
IDisposable disposable1= enumerator1as IDisposable;
if (disposable1 !=null)
{
disposable1.Dispose();
}
}
builder1.Append(']');
return builder1.ToString();
}


Variable table1 wasn't used.
Serialize(set1) rises Stack Overflow exception

Returning a datatable

Based on trying to return a DataSet, I have decided to try and justreturn a DataTable (fyi. http://forums.asp.net/1077805/ShowPost.aspx).
The problem is that in my javascript callback, I need to get at thedata that is returned. What methods are available on the returneddata? I have a datatable with several datarows, but I don't knowwhat methods are available to actually get at the data. BTW, I amtrying to do this programmatically and am not interested in adeclarative solution to this. When I attempt to alert out to theUI, result.length is coming through a undefined.
Web Service:
[WebMethod]
public System.Data.DataTable ReturnDataSet()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("tblStateId",System.Type.GetType("System.Int32")));
dt.Columns.Add(new DataColumn("State",System.Type.GetType("System.String")));
dr = dt.NewRow();
dr["tblStateId"] = 1;
dr["State"] = "Tennessee";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["tblStateId"] = 2;
dr["State"] = "Alabama";
dt.Rows.Add(dr);
return (dt);
}
Client Side Javascript:
function LoadTest(){
Samples.AspNet.WebServiceTest.ReturnDataSet(ReturnDataTableCallBack);
}

function ReturnDataTableCallBack(result)
{
var i = 0;
var ddl = document.getElementById("sState");
var optionItem;
iLength = document.getElementById("sState").options.length;
document.getElementById("sState").visible = true;
document.getElementById("txtAreaResult").value = result.get_data();
for(i=0; i<iLength; i++)
{
document.getElementById("sState").options[0] = null;
}

for(i=0; i<result.length; i++)
{
document.getElementById("sState").options.add(newOption(resultIdea [I]["State"],resultIdea [I]["tblStateId"]))
}
}


I think you should be able to write code like:
for (var i = 0; i < results.get_length(); i++) {
alert(results.getItem(i).State);
}
As a side note: there are several ways that you can use to 'discover'the structure of an object. One way is to usedebug.dump(object,name[,recursive[,indentationPadding]]), which shouldadd information about an object to the trace. Another way is to loopthrough the members of an object, like "for (m in myObject) alert(m);".

Great information. It got me on the right track. I foundthat the following pseudo-javascript was what was necessary:
for(i=0; i<result.get_length(); i++)
{
var optAdd = newOption(result.getItem(i).getProperty("State"),result.getItem(i).getProperty("tblStateId"));
document.getElementById("sState").options.add(optAdd);
}
The .State and .tblStateId properties did not return a value, but thegetProperty("State") and getProperty("tblStateId") did what wasnecessary.
Do you have a complete example of the debug.dump() method?
Wally

You could use "get_State()" instead of "getProperty('State')" too (which I think is nicer).
To use debug.dump, try something like "debug.dump(results, "my results", true)".

How would you do this declaratively? For example, if I wanted to bind the first state returned to a label...I've tried this, and it doesn't work:
<binding id="binding1" dataContext="dataSource1" dataPath="data[0].State" property="text" automatic="false" />
I can't figure out what to put in the dataPath. Anyone have some guidance?

Returning a Form for Master Detail pages.

So I am trying to do something in .NET with AJAX that I do rather easily in jsp. It seems like such a common thing, I can only assume that I am just not googling the right terms, and any help would be apreciated. Here's the scenario:
Standard master detail says show a list of items, click one, be taken to a form to edit the item. What I'm looking for is the click on the link just populates the form for the proper item, which is rendered either below or to the right of the list. User edits the item, clicks a button on the form, the form is submitted (also just that region submitted, not the whole page), and a message for success or failure is shown.
I am able to do this with ease in jsp with several frameworks but am now working in the .NET arena and am having no end of trouble. I get as far as:
display the list
onclick call and ajax function (currently using AJAX.NET)
proper method gets called
I render a custom user control (contains a form) into an htmlTextWriter backed by a TextWriter backed by a StringBuilder, and I return that string to replace the content of a div on the page.
Several problems:
Why the need to jump through hoops with the various writers? Is there an easier way to just render a page snippet/custom control into the response stream?
Is there or will there be a facility to return server generated controls/control hierarchies from the server with Atlas?
What am I missing here? Any help would be greatly appreciated.
Thanks

You may want to try the refresh panel library:http://www.gotdotnet.com/Workspaces/Workspace.aspx?id=cb2543cb-12ec-4ea1-883f-757ff2de19e8
Or wait for Atlas to implement similar features.
Thanks for the link - I'll check it out.

Returning dynamic JSON from ASP.Net

I have an ASP.Net web service that I want to return a JSON response. The method that I am working on in particular calls another web service that already gives me a JSON response. All I want to do is return that to the caller of my webservice (it will be a .htm/.js caller).

I have already found a way to make it work, but it doesn't seem optimal. If I define some local objects in my web service that look like the JSON response I get from the third party web service, I can deserialize the response into my local objects, and return the object from my web service. If I call the service from the browser with the JSON request type, I get back the correct JSON response. But in this case I have taken a JSON string, converted it to an object and back again, which seems like too much work. Plus, I'll have an extra layer of objects that have to be kept in sync with the third party response.

If I just return the JSON that I get from the third party webservice (as a string), in the browser I get a string that can't be EVAL'd into a js object. It has quotes around the whole thing and all the internal quotes are escaped, etc. It is basically just a string, not JSON.

So, the question is, how can I define a web service method that returns any JSON that can be called from a simple htm/js client and get it to return valid (ready to eval) JSON? What return type should I be using?

Backslider

ASP.NET AJAX web services only support returning objects. These objects will be serialized by the AJAX services layer. There is no returntype to hold raw JSON , and skip this serialization.

However if you return the JSON as a string, you should be able to eval the response once to get the string response from thirdparty webservice(If you use a proxy generated by ASP.NET AJAX it would returned an already eval'ed response). Once you get the string, you should be able to eval it again to get the actual js object.


Have you tried letting your server convert it into a .Net object?

Returning Exceptions

Hi

Using the example:
http://atlas.asp.net/quickstart/atlas/doc/services/default.aspx#catchingExceptions

Both IE and FF throw javascript errors

FF: result has no properties
IE: 'null' is null or not an object - 'null' being the result argument from the OnError callback method

See for youself:
http://atlas.asp.net/quickstart/atlas/samples/services/ExceptionPage.aspx

Is this a bug with the Jan06 release? What is the best way around this?

Craig

I just downloaded the Jan06 release and I'm experiencing the same problem...


Hi people,

i'm using January release also, when i run the example from the Atlas quickstart site, i got the same exceptions.

But if i try the example locally (copy the examples to my computer Atlas site), they are working well.

I think the Atlas site is using an older release.

So, Atlas team please, update the quickstart samples site. It's very important for the people who are starting with Atlas have confidence about the samples

This way it's much harder to find the errors.


Actually, I can reproduce the problem running the example locally. In my scenerio, I use an ASPX page to host the web method as follows:

MyPage.aspx.cs
[WebMethod]
public void GetData() {
throw new ArgumentException("throw exception");
}

MyPage.aspx
<scriptlanguage="javascript"type="text/javascript">
functionCallServer() {
PageMethods.GetData(,OnComplete, OnTimeout, OnError);
}

function OnComplete() {
alert("Complete");
}

function OnTimeout(result) {
alert(result);
}

function OnError(result) {
alert(result);
}
</script>

<!-- Call the server from a HTML button -->
<inputtype="button"value="Call Server"onclick="CallServer();"/>


you're right,

If i move the method to the same page, i got a null argument in the error delegate.

I tried to add

<atlas:ScriptManagerID="scriptManager"runat="server"EnablePartialRendering="true"

OnPageError="OnScriptManagerPageError">

<ErrorTemplate>

Ha ocurrido un error al procesar esta acción.<br/>

<spanid="errorMessageLabel"></span>

<hr/>

<buttonid="okButton"type="button">

OK</button>

</ErrorTemplate>

</atlas:ScriptManager>

and the server script

<scripttype="text/C#"runat="server">

[WebMethod]

publicvoid ExceptionTest(String someParam)

{

thrownewInvalidOperationException("foo");

}

protectedvoid OnScriptManagerPageError(object sender,PageErrorEventArgs e)

{

// Set e.ErrorMessage to something you want to send down to the client

e.ErrorMessage = (String.IsNullOrEmpty(e.Error.InnerException.Message)) ? e.Error.Message : e.Error.InnerException.Message;

}

</script>

as i have seen at

http://www.nikhilk.net/AtlasM1Refresh.aspx

and the server function OnScriptManagerError is not called, even i checked with fiddler that the server response code is 500.

I'd like to know how to use the new feature of page error handling


Same problem here.
I'm executing a WebMethod and the error handling are returning a null value.

Somone knows how to catch error returned from the WebMethod?

It's a bug in Jan06?


hello guys.

well, i may be wrong since i've only started lookig at atlas today and i've also got this bug while throwing exceptions from web methods defined on the page. after trying to do some debugging, it looks like the problem is on Web.Net.WebResponse.get_objectmethod. the problem is that it gets the result and tries to deserialize it. however, when a method on a page throws an error, the result that is received on the client part is an html page which de JSON can't deserialize. this seems like a bug on the scriptmanager (is this the component that handles server side processing when one calls methods on a page? - ehy, don't forget that i just started today on this :) )
Hi,

we can distinguish 3 cases:

1) The Exception is raised in a method defined in a WebService.
In this case, an instance of the class Web.Net.MethodRequestError issent to the client. This object exposes three properties that give infoon the particular Exception raised: get_message(), get_stackTrace(),get_exceptionType().

2) The Exception is raised during an asynchronous postback.
This means we have declared at least one UpdatePanel. The Exception canbe raised, for example, in an event handler during the Page lifecycle.
In this case, the ScriptManager is able to send the error message downto the client and to display it using its <ErrorTemplate />.Moreover, the server can format the message to be sent to the client byhandling the PageError event of the ScriptManager.

3) The Exception is raised when calling a [WebMethod] defined in a Page.
In this case, no exception handling is performed by the Atlasframework, and the client receives (in the response) the tipical HTMLpage that is displayed on ASP.NET pages when an Exception is raised.

At this point, the the error callback could be declared in this way:

function onError(objError, response) {
if(objError) {
// Got a MethodRequestError instance.
}
else {
// Custom error handling.
alert(response.get_statusCode());
}
}

While the objError parameter is null, the second parameter is theresponse object and we can use it to display, for example, an alertwith the HTTP status code (obviously, while waiting for an improved exception handling in the next release).
hello.

yes, i got into that conclusion after debugging the atlas script file...i think that it should be fixed before the final release...

Returning Focus to the top of the page

I have two panels over laying each other. When the user click a button at the bottom of the first panel, that disappears and the panel on top appears, when the event triggers and the Ajax response is processed the page focus remains where the button that was clicked once was and as the information on the second panel is at the top of the page, the user has to scroll up to the top each time. This is obivously something to do with Ajax, but I can't get the page to return to the top. I have tryed using a invisible text box and setting that as having focus when the second panel appears, but this does not work either.

Any suggestions?

I would link internally to the page. So if you're onhttp://www.someurl.com/somepage.aspx after the Ajax, link internally tohttp://www.someurl.com/somepage.aspx# which will jump to the top of the page.

Alternatively you can do a setFocus call to the <body> tag or some other element that is at the top of the page.

Regards,

Tim

Returning results from a page method call

In my ASP.NET AJAX web site, I am attempting to use Page Methods to return data from the web server. I would like to be able to return the value from a page method like so:

function GetValue()
{
return PageMethods.GetValueFromServer();
}

function ManipulateValue()
{
var myValue = GetValue();

// Do something with myValue
}

Unfortunately, calling a page method requires the use of a callback function. I really need to retrieve the value without having to store it in a global variable in the callback function; is there any way to do this?

function GetValue(){ return PageMethods.GetValueFromServer( function(result){// The result that is returned from server //Now do what ever you would like to do.} );}
Maybe you can try something like this

KaziManzurRashid:

function GetValue()
{
return PageMethods.GetValueFromServer(

function(result)
{
return result;
}

);
}

Maybe you can try something like this


I tried your code, returning the result in the nested callback function (see above), but when I returned to the code that calls GetValue() the value that ends up getting returned is undefined. :-(


Yes that becasue the ajax call is async. it does not wait for the ajax call to complete, why do not you call the GetValue in the Callback?


KaziManzurRashid:

Yes that becasue the ajax call is async. it does not wait for the ajax call to complete,why do not you call the GetValue in the Callback?



Okay, I'm somewhat confused. I call GetValue(), which calls an asynchronous server method and is passed an in-line Javascript callback function. Are you saying that I should, in the callback function, call GetValue() again? If so, won't that just cause an infinite loop?


Sorry let me rephrase. You do not need to call the GetValue again in the callback although doing it will not make it recursive. You can call your desired outer ManipulateValue function in the callback but in that case the ManipulateValue will not again call the GetValue.


KaziManzurRashid:

Sorry let me rephrase. You do not need to call the GetValue again in the callback although doing it will not make it recursive. You can call your desired outer ManipulateValue function in the callback but in that case the ManipulateValue will not again call the GetValue.

Okay, I tried that but still no luck. Here is the code I am using; perhaps you can shed some insight on to what I'm doing wrong? It looks like this is, in fact, causing an infinite loop.

Javascript code:

function PrintDateTime()
{
var dateTimeFromServer = RetrieveDateTime();
$get("myLabel").innerHTML = dateTimeFromServer;
}

function RetrieveDateTime();
{
return GetAjaxValue();
}

function GetAjaxValue()
{
return PageMethods.GetCurrentDateTime(
function (result)
{
return RetrieveDateTime();
}
);
}

C# code:

[WebMethod]
public static string GetCurrentDateTime()
{
return DateTime.Now.ToString();
}


You can do it in the following way:

function GetAjaxValue(){ return PageMethods.GetCurrentDateTime( function (result) { $get("myLabel").innerHTML = result; } );} function showCurrentDateTime(){GetAjaxValue();}

Just call the showCurrentDateTime in your code when you want to show it.


KaziManzurRashid:

You can do it in the following way:

function GetAjaxValue()
{
return PageMethods.GetCurrentDateTime(
function (result)
{
$get("myLabel").innerHTML = result;
}
);
}
function showCurrentDateTime()
{
GetAjaxValue();
}

Just call the showCurrentDateTime in your code when you want to show it.

Thanks for the time you've spent addressing my questions, Kazi. Unfortunately, in my code I really need to return the value in the RetrieveDateTime() function. The code in PrintDateTime() is just used for illustration; I need to do more than just put it in a label. To clarify, here's exactly what I want to do:

var myValue = RetrieveDateTime();

The value is not being displayed on screen but is being used by logic within a JavaScript function. I really just want to be able to call a JavaScipt function and return a value that I can use in the rest of the code.


Hi, Well you have to undertand the nature, it is always. and thats why the best place to assume the value is availabe is the Callback. If you can describe more of your scenerio then I can help.


Hi,

Thank you for your post!

It seems that you have misunderstanding on AJAX and callback.

The result cann't be obtained like this:

var myValue = GetValue();

It must be obtained like this:

function SetSessionValue(key, value)
{
PageMethods.SetSessionValue(key, value,
OnSucceeded, OnFailed);
}

// Callback function invoked on successful
// completion of the page method.
function OnSucceeded(result, userContext, methodName)
{
if (methodName == "GetSessionValue")
{
displayElement.innerHTML = "Current session state value: " +
result;
}
}

// Callback function invoked on failure
// of the page method.
function OnFailed(error, userContext, methodName)
{
if(error !== null)
{
displayElement.innerHTML = "An error occurred: " +
error.get_message();
}
}

For more information about callback and webmethod, seehttp://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx

If you have further questions,let me know.

Best Regards,

Returning selected value from ModalPopup in a custom web control

I'm a little lost on how to do this conceptually -- can someone perhaps shed a little light on how this might be done?

    Custom web control consists of UpdatePanel with other UI controls and a ModalPopupExtender. The purpose is to be a reusable search popup, and I've got the search UI functionality working like a champ.

    Page with an UpdatePanel containing some container (textbox, listbox, label, etc), a linkbutton, and my custom control from #1.

What I would like to do is have the linkbutton call some script (be it client- or server-side, not sure what's the most appropriate yet) that does the following steps:

    Show the custom popup

    Allow the user to perform the search and select one of the results, which would close the popup

    Snag the selected value from my popup, then work with that value to update the container (i.e. if it's a listbox, then do some script to insert an appropriate item)

How can I pull this one off, so the search popup is an isolated, reusable control? I've got different instances where I need the selected value to change a Label, update a TextBox, or even be inserted in a ListBox. I've got plenty of public properties on the custom control already that determines the parameters for the search itself; is there a perhaps way to override the Show() method so that it would return the value of the selection after it closes? But since Show() wouldn't really block, I'm lost on how to do it.

Thanks a lot,
Jon

Am I screwed on this one? The best I've been able to get are two separate custom controls with a LOT of duplicated code ...

Control contents: Listbox, linkbutton to show popup, all the popup code

Then repeat with a new control replacing the Listbox with a Label etc ...

I hate having this much duplicated code; anytime I need to change the popup code I'll have to duplicate it in each of my custom controls. There has to be a better way to do this?!?


I am not sure if i understand you question 100% from what ive read but if you want to get a value return from the mod popup is should not be to hard.

Lets say i have a mod popup that has a textbox, a search button, a listbox of results and a submit button. What you could do is once you have run the search which you said is working great, display the results in the listbox in the popup. then when the user clicks the submit button an event is fired that checks to see if they selected one of the items in the list box, if not then it will tell them to do so. Then if you want to use that selected value to populate a listbox on the main for (say for example you searched in the popup for a street name and then selected the right street name from the listbox and clicked submit and you want the main form listbox to display all people on that street) then all you need to do is have the event for the submit button Click call a function you write that runs the query to get all people on that street and print their info the the list box.

It should not be hard to get the results from the popup, but im not sure i understand what you are asking so this could be no help at all :P


Well! There's a little different between the concept of Modal Popup in Windows and Web forms. The latter is just hiding all the controls in the Popup and show when needed but you should able to access the properties of those controls within the scope of the page.

Now, assuming that you want to create a ASP.NET reusable custom server control that "know-how" to popup a modal to collect data from the end-user. The basic class design can be used so you just have to declare a public property so that it can return the selected value. Another alternative is you can use a Session key to store the value so that the class container can retrieve after using your class. This key can be set as a property of your class prior to the container is using it.

I hope it help since your question left a lot of detail out hence it's not very clear.


My apologies for not being clear enough -- I think I wrote the initial post after too much coffee and a bit too much frustration. :(

The overall project is an admin web UI for AD objects, so popup searches are going to be very common. Some pages will have multiple popup searches, so it is my desire to completely wrap all of that functionality into a single reusable custom server control. The results of the search could be used to update different types of UI elements on the parent page; my struggle is with conceptually figuring out where the pieces go to make this work in more than one situation.

My custom control now is an UpdatePanel with all the search UI and tidbits inside, and a ModalPopupExtender. There are many public properties on my control, mostly to define how the search itself is going to work. TargetControlID for the extender is also exposed as a public property, so that I can wire the popup to any UI element on the parent page that I want. The control also has a hidden element in it; this hidden element eventually contains the selection the user chose from the search results and is exposed via a public "SelectedResult" property.

Everything up to this point is working 100%. I'm stuck, however, on implementing the hooks for getting the value back to the parent page. Once someone clicks the TargetControl and performs the search and selects a result (which then hides the popup through server script in the control itself), the result is stored in the hidden element and the user is back at the parent page. But how do I work with that SelectedResult then? I should be able to, once the popup is hidden, take that value and stick it somewhere on the parent page -- but apparently I'm missing something obvious, because I'm completely lost.

Do I handle it via a custom click event for the wired target (instead of just using TargetControlID)? Does OnOKScript fit in here somewhere? Since the activity to take place after a selection is made will be different depending on the situation, it needs to happen outside of my custom control. Are there additional extender props that I need to expose through a public property on my custom control?

I hope this helps -- I'm not seeking exact code samples, I'm more looking for help on getting my brain wrapped around the "how" of the solution ... the exact code I should be able to figure out after that, I think. If some of my code for certain parts would help, I'll be happy to post them -- just let me know. Thanks again!


Alright so im still not sure if this is anything helpful, but i have a small example here i wrote of what i would do to put the result from my modal popup into my main page and from there i could do what ever i want with it. I tried to comment the best i could to make it super easy to read

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using AjaxControlToolkit;public partialclass administration_OIS_Default : System.Web.UI.Page{ ModalPopupExtender modPop =new ModalPopupExtender();//The main modal popupprotected void Page_Load(object sender, EventArgs e) { HiddenField results =new HiddenField();//Results from mod popup HiddenField hidden =new HiddenField();//Mod popup targetID UpdatePanel update =new UpdatePanel();//UpdatePanel to hold controls TextBox tempText =new TextBox();//Textbox for mod popup Button btnVisible =new Button();//Button to show mod popup Button btnSubmit =new Button();//Submit button in mod popup Panel container =new Panel();//Panel to hold controls for mod popup //Assign IDs to variables that need to be refrenced later container.ID ="Container1"; results.ID ="Result1"; hidden.ID ="Hidden1"; btnVisible.Text ="Click to show modPop"; btnVisible.ID ="visibleButton"; btnVisible.Click +=new EventHandler(this.btnVisible_Click);//Tell the button what do do when click update.ContentTemplateContainer.Controls.Add(btnVisible);//Add the button to main update panel update.UpdateMode = UpdatePanelUpdateMode.Conditional;//We only want the panel to update sometimes update.ChildrenAsTriggers =true;//IE. when child controls trigger it update.ContentTemplateContainer.Controls.Add(hidden);//Add "hidden" to the update panel tempText.ID ="textBoxTest";//Add a simple textbox to the control container.Controls.Add(tempText);//container to be placed in our modal popup btnSubmit.Text ="btnSubmit"; btnSubmit.ID ="btnSubmit1"; btnSubmit.Click +=new EventHandler(this.btnSubmit_Click);//tell submit what to do when clicked container.Controls.Add(btnSubmit);//and add it to our control container modPop.TargetControlID = hidden.ID;//We would rather use modpopup.Show() so we make this a hidden field modPop.PopupControlID = container.ID;//Define the object to be shown inside of mod popup modPop.DropShadow =true;//Why not a little style :P modPop.X = 500; modPop.Y = 250; update.ContentTemplateContainer.Controls.Add(modPop);//Add the modal popup to our update panel update.ContentTemplateContainer.Controls.Add(results);//Add our results holder to the update panel update.ContentTemplateContainer.Controls.Add(container);//Also add the modal popup contents form1.Controls.Add(update);//Add our updatepanel to the main form }/// <summary> /// Function will force the modalPopup extender function .Show to fire /// </summary>private void btnVisible_Click(object sender, EventArgs e) { modPop.Show(); }/// <summary> /// Function takes the users input from the modal popup and saves it to a hidden field /// located in the updatepanel so that it will be save for further use /// </summary>private void btnSubmit_Click(object sender, EventArgs e) { ((HiddenField)form1.FindControl("Result1")).Value = ((TextBox)((Button)sender).Parent.Controls[0]).Text; }/// <summary> /// Function will display the saved value from the modal popup to prove that it works /// </summary>private void showText() { txtOutput.Text = ((HiddenField)form1.FindControl("Result1")).Value; }/// <summary> /// Occurs when button1 is clicked, showing the save results from modal popup /// </summary>protected void Button1_Click(object sender, EventArgs e) { showText(); }}
 So basically the user will click a button here to show the modal popup. enter text and click submit in the modal popup, and then they are brought back to the main form where if they click on Button1,
the value that they entered into the modal popup will be displayed. I got lazy at the end and didnt add txtOutput or Button1 programmatically so if you want to run this code on your own i think those are
the only 2 things you will have to manuall add to the form
Enjoy

You know what, I think I've got it ... maybe I just needed to "air it out" and let my mind wander for a bit. Seems like it would be simple after all, let me know if I'm off base:

I could just have the custom control expose another public property, and the parent page sets that property to a hidden control on the PARENT PAGE. Then the custom server control sets that hidden control's value before calling hide(). The hidden control on the parent page would have an onChanged() event that could do whatever UI update activity is necessary. That would keep all of the code separate from the custom control, allowing it to work in any situation I needed.

I'm going to try that right now ... if it is indeed this simple, my apologies for going around in circles on this one Embarrassed


Sounds like your on the right track now, well at least the track that I felt is what would help you get to where you want to go. and yeah, sometimes its best to take your mind of things then come back with a different perspective, or go onto forums like this and let someone else share their point of view, it saves a lot of frusterationSmile


It actually turns out to be even simpler -- I just need my custom control to raise a public event when the user selects a search result, and passes the selection as part of the args. The consuming page just watches for that event and does whatever UI magic is necessary as a result. No hidden fields or other stuff in the middle.

Amazing how much clearer things get after talking it out. Thank you everyone for your help and patience -- I'll try to make this control available publicly shortly and post a link in this thread; your help has been invaluable!


invaluable, wow i feel specialBig Smile


Can you please give some example on how the modal popuo raises a public event and how the parent page watches for the event? Thanks.

jmbutler:

It actually turns out to be even simpler -- I just need my custom control to raise a public event when the user selects a search result, and passes the selection as part of the args. The consuming page just watches for that event and does whatever UI magic is necessary as a result. No hidden fields or other stuff in the middle.

Amazing how much clearer things get after talking it out. Thank you everyone for your help and patience -- I'll try to make this control available publicly shortly and post a link in this thread; your help has been invaluable!


Sure thing!

My ModalPopup is completely contained in a custom web control, so in that control's code I've first defined the custom event that I will raise, including a custom derived EventArgs class that will include the information about which search result the user selected:

public delegate void ResultSelectedEventHandler(object sender, SelectedEventArgs e);public event ResultSelectedEventHandler ResultSelected;public class SelectedEventArgs : EventArgs {public string Selection;public SelectedEventArgs(string selection) {this.Selection = selection; } }protected virtual void OnResultSelected(SelectedEventArgs e) {if (ResultSelected !=null) ResultSelected(this, e); }

Then in the click code for my selection button, I raise this event before hiding the popup ("RadioSelect" is a radio button from my search panel's GridView; it's value is a two-dimensional string array separated by '|'):

protected void lnkAddSelected_Click(object sender, EventArgs e) {// raise an event to notify the consuming page that a selection was made OnResultSelected(new SelectedEventArgs(Request.Form["RadioSelect"]));// we're done; close the popup ModalPopupExtender1.Hide(); }

Now, back on the consuming parent page, I subscribe to this event in the markup of my custom control (note I've exposed TargetControlID publicly as well so I can wire my custom control to anything I want):

<uc2:PopupADSearch ID="PrimaryOwner" runat="server" TargetControlID="lnkChangePrimaryOwner" OnResultSelected="PrimaryOwner_Selected" />

Finally, in the code for my parent page, I define the PrimaryOwner_Selected method:

protected void PrimaryOwner_Selected(object sender, PopupADSearch.SelectedEventArgs e) {string[] selection = e.Selection.Split('|'); hidPrimaryOwner.Value = selection[0]; lblPrimaryOwner.Text = selection[1]; }

It's also important to note that the custom control, hidPrimaryOwner (a hidden control), and lblPrimaryOwner (a typical label server control) are all within an UpdatePanel -- otherwise all this jazz wouldn't work without a full-page postback. Hope you find this useful!


Hi,

From this post, I felt that you guys h've worked in Modal popup extender. I am posting my question expecting help if anyone knows.

I display Modal Popup( which shows the grid rows and button controls in panel) on clicking imagebutton. I want to align the the button in panel to center ans currently its left aligned and looks awkward. Can anyone tell me how do we align the button control in Model Popup's panel..

Here is the existing code.

Code forbtnSubmit is underlined in Italic in below code for easy identification.

///<summary>

/// Event Handler for Grid selection

///</summary>

///<param name="sender"></param>

///<param name="e"></param>

protectedvoid apprvlsGrid_SelectedIndexChanged(object sender,EventArgs e)

{

if (apprvlsGrid.SelectedIndex >= 0)

{

vwbenftsImgBtn.Visible =true;

string gridAprveSwID;

// Validations on Approve and reject buttons using javascript

if(apprvlsGrid.SelectedIndex <= 7)

gridAprveSwID ="ctl00_ContentPlaceHolder1_apprvlsGrid_ctl0"

+ (apprvlsGrid.SelectedIndex + 2) +"_approveSwHdn";

else

gridAprveSwID ="ctl00_ContentPlaceHolder1_apprvlsGrid_ctl"

+ (apprvlsGrid.SelectedIndex + 2) +"_approveSwHdn";

apprvBtn.Attributes.Add("OnClick","return fnaprvValidate('" + gridAprveSwID +"')");

rejectBtn.Attributes.Add("OnClick","return fnrejValidate('" + gridAprveSwID +"')");

// Controls declared dynamically for Modal Popup using Ajax

Button vwbenftsBtn =newButton();

Button btnSubmit =newButton();

Panel container =newPanel();

container.Width = 400;

container.Height = 350;

container.BorderWidth = 1;

container.BackColor =Color.WhiteSmoke;

GridView benfGrd =newGridView();

//Assign IDs to variables that need to be refrenced later

container.ID ="Container1";

benfGrd.ID ="benfGrd";

benfGrd.AutoGenerateColumns =false;

benfGrd.Width = 400;

benfGrd.Height = 300;

Literal newline =newLiteral();

Literal spaces =newLiteral();

Approvals apprvls;

Approval aprvalVwBenfts =newApproval();

if (Session["aprvlsList"] !=null)

{

apprvls = (Approvals)Session["aprvlsList"];

int iApprvlsCount = apprvls.Count;

GridViewRow aprvlsSelectRw = apprvlsGrid.SelectedRow;

aprvalVwBenfts.BinId =Convert.ToInt64(aprvlsSelectRw.Cells[13].Text);

aprvalVwBenfts.CardId =Convert.ToInt64(aprvlsSelectRw.Cells[14].Text);aprvalVwBenfts.SetId =Convert.ToInt64(aprvlsSelectRw.Cells[15].Text);

aprvalVwBenfts.TableCd = aprvlsSelectRw.Cells[17].Text;

aprvalVwBenfts.EffDate =Convert.ToDateTime(aprvlsSelectRw.Cells[7].Text);

aprvalVwBenfts.SetDesc = aprvlsSelectRw.Cells[6].Text;

if (aprvalVwBenfts.TableCd =="B")

aprvalVwBenfts.TableID = aprvalVwBenfts.BinId;

else

aprvalVwBenfts.TableID = aprvalVwBenfts.CardId;

for (int iRow = 0; iRow < iApprvlsCount; iRow++)

{

if (aprvalVwBenfts.TableID == ((Approval)apprvls[iRow]).TableID

&& aprvalVwBenfts.SetId == ((Approval)apprvls[iRow]).SetId

&& aprvalVwBenfts.TableCd == ((Approval)apprvls[iRow]).TableCd&& aprvalVwBenfts.EffDate == ((Approval)apprvls[iRow]).EffDate)

{

int isetBenftCOunt;

isetBenftCOunt = ((Approval)apprvls[iRow]).getSetBenefitCount();

SetBenefit[] setSetBefts = (SetBenefit[])((Approval)apprvls[iRow]).getSetBenefits();

//Loads the Modal Pop up controls

// Dynamically create field columns to display the desired

// fields from the data source. Create a TemplateField object

// to display an author's first and last name.

TemplateField benfGridCol =newTemplateField();

// Create the dynamic templates and assign them to

// the appropriate template property.

benfGridCol.ItemTemplate =newGridViewTemplate(DataControlRowType.DataRow,"");

benfGridCol.HeaderTemplate =newGridViewTemplate(DataControlRowType.Header, aprvalVwBenfts.SetDesc);

// Add the field column to the Columns collection of the

// GridView control.

benfGrd.Columns.Add(benfGridCol);

benfGrd.DataSource = createGridData(setSetBefts, isetBenftCOunt);

benfGrd.DataBind();

vwbenftsImgBtn.ID ="vwbenftsImageBtn";

vwbenftsImgBtn.ToolTip ="View Benefits for Selected Set";

//vwbenftsImgBtn.Click += new ImageClickEventHandler(this.vwbenftsImgBtn_Click);

container.Controls.Add(benfGrd);

btnSubmit.CssClass ="btn";

btnSubmit.Text ="Close";

btnSubmit.ID ="btnSubmit1";

newline.ID ="newline";

newline.Text ="<br/> ";

//spaces.ID = "spaces";

//spaces.Text = "aaaaaaaaaaaaaaaaa";

//spaces.Visible = false;

//subBtnTble.Style = "center";

//subBtnTble.ID = "subBtnTble";

//subBtnTble.Controls.Add(btnSubmit);

container.Controls.Add(newline);

//container.Controls.Add(spaces);

container.Controls.Add(btnSubmit);

// Specify the Image button as Modal Popup target

modPop.TargetControlID = vwbenftsImgBtn.ID;

//Define the object to be shown inside of mod popup

modPop.PopupControlID = container.ID;

modPop.DropShadow =true;

modPop.X = 250;

modPop.Y = 100;

modPop.OkControlID = btnSubmit.ID;

// Add all the controls to Page's form

formApvl.Controls.Add(vwbenftsImgBtn);

formApvl.Controls.Add(modPop);

formApvl.Controls.Add(container);

}

}

}

}

}

Thanks

Shilpa


Actually, I don't think this has anything to do with this thread -- your question is more geared towards HTML / CSS. You can center any HTML entity using appropriate CSS. If you need more specific answers, I would recommend starting a new thread entirely in one of the other forums (while you are referring to an AJAX extender, your question really has nothing to do with AJAX.)

returning undefined values in autocomplete textbox

Hi ,

I am using autocomplete textbox in my applocation using webservices. When i was running the applications i am getting values in the div as undefined

here's my html code:

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:TextBoxID="TextBoxSiteNumber"Width="130px"runat="server"AutoPostBack="true"></asp:TextBox><asp:ImageButtonID="ddlSite"ImageUrl="../../Images/listarrow2.png"runat="server"ImageAlign="AbsMiddle"/>

<cc4:AutoCompleteExtenderID="AutoCompleteExtender1"CompletionInterval="1000"EnableCaching="true"ServiceMethod="GetSiteInfo"ServicePath="~/WebService1.asmx"MinimumPrefixLength="1"TargetControlID="TextBoxSiteNumber"runat="server"completionlistelementid="AutoComplete"FirstRowSelected="true"CompletionListCssClass="autoComplete">

</cc4:AutoCompleteExtender>

<divid="AutoComplete">

</div>

I wrote code in webservice1.asmx as follows:

<WebMethod()> _

<System.Web.Script.Services.ScriptMethod()> _

PublicFunction GetSiteInfo(ByVal prefixTextAsString)AsString()

Dim countAsInteger = 10

Dim sqlAsString ="Select distinct Top 5 UN_BREF from DM_UNIT Where UN_BREF like @dotnet.itags.org.prefixText"

Dim SQLConAsNew System.Data.SqlClient.SqlConnection("Server=orbis6;User Id=tims;Password=tims;Database=REGIS")

Dim daAs SqlDataAdapter =New SqlDataAdapter(sql, SQLCon)

da.SelectCommand.Parameters.Add("@dotnet.itags.org.prefixText", SqlDbType.VarChar, 50).Value = (prefixText +"%")Dim dtAs DataTable =New DataTable

da.Fill(dt)

Dim items()AsString =NewString((dt.Rows.Count) - 1) {}

Dim iAsInteger = 0

ForEach drAs DataRowIn dt.Rows

items.SetValue(dr("UN_BREF").ToString(), i)

i = (i + 1)

Next

Return items

EndFunction

My web.config file looks as follows:

<httpHandlers>

<removeverb="*"path="*.asmx"/>

<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>

</httpHandlers>

<httpModules>

<addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

Please anyone help me

Thanks in advance

Please anyone reply to this post. its very urgent to implement in my application. Waiting for anyone's reply

Thanks In Advance


<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManager>



Hi ,

I solved it with the help of following link

http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=13342

Thanks

Returning Values with DynamicPopulateExtender

Hi guys,I need to update two different values on a page, which I'd like to calculate at the same time (Monthly Value and Annual Value). Is it possible to get DynamicPopulateExtender to return two values for different controls?It's not a simple case of *12 for Annual value, and it would really reduce processing time if I could calculate both at the same time.Andi

From what I understand, I don't think so. What about just using two UpdatePanels?

Returning web service result from calling function in javascript (Atlas)

When using Atlas is there a way that I can call a web service method and have the result returned from the calling function. I understand that Atlas works asynchronously and therefore uses callback functions but I need the calling function to return the result somehow.

I tried something similar to the following but it didn't work. It seems to be that the global variable only gets updated once the calling function completes.

var getResult;
function LMSGetValue(param) {
// Note that the LMSAPI is setup with a ScriptManager
LMSAPI.LMSGetValue(param,LMSGetValueComplete);
pause(1000);// helper function that pauses by # millisecs
return getResult;
}
function LMSGetValueComplete(param) {
getResult = param;
}

The reason that I have to return the result from the calling function is that the javascript that calls the function (which is located in a iframe) follows a strict specification called SCORM which is used for building sharable elearning content and learning management systems (LMS). The learning content in the iframe calls the LMSGetValue function to get the data from the LMS and expects a return value.

Any help or suggestions on how I might be able make this scenario work would be grately appreciated as I really am quite stuck.

Unfortunately there is no current support for synchronous webservice calls, you cannot return a value from your method directly, the results are only available thru your callback.