Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pagemethod onsuccess event not firing

Status
Not open for further replies.

tekkerguy

Programmer
Nov 16, 2005
196
US
I've had this post in the c# section for a week and a half now, realized it should be here, and I don't know how to move a message, so please forgive the double post, and if there's a way to move messages, let me know and I'll do so.





My Pagemethod fires c# code which submits a record to a database, this is working.

But I have some js code stored in an onsuccess method, which should alert that the record was submitted, but it's not firing.

Here's the js: (the data gathering part of the js code is omitted, it's not necessary)

CODE
function submitfunction()
{
if (doSubmit == false)
{
alert("The Following items need a value: \n \n" + errorList);

}
else
{
PageMethods.submitForm(pagewoTable, pagecfTable, OnSubmitComplete, OnManuFailed);
}

}



function OnSubmitComplete(results)
{
debugger;
alert("Crane Saved Successfully");
//window.close();
}

/* Failed Manufacturer Load */
function OnManuFailed(error)
{
//debugger;
alert("Stack Trace: " + error.get_stackTrace() + "/r/n" +
"Error: " + error.get_message() + "/r/n" +
"Status Code: " + error.get_statusCode() + "/r/n" +
"Exception Type: " + error.get_exceptionType() + "/r/n" +
"Timed Out: " + error.get_timedOut());
}


and here is the cs code:


CODE

//This Event submits the Form

[WebMethod]

public static string submitForm(string woTable, string cfTable)
{
string craneID = "";

try
{
craneID = staticInsertCrane(cfTable);
}
catch (Exception f)
{
string error = f.ToString();
return "failed";
}

try
{
staticcreateWorkOrder(woTable, craneID);
return "success";
}
catch (Exception g)
{
string error = g.ToString();
return "failed";
}

//return true;
}


Again, the crane is successfully submitted, but it the success event, doesn't fire.


also here's the submit button



<asp:Button runat="server" ID="submitterButton" Text="Add Drawing" OnClientClick="submitForm();" />







Any ideas?
 
I'm not a big C# / ASP.NET user, so I don't know if I'm giving the right answer here or not, but every little bit helps, right?

The Javascript line where you call the submitForm method is passing 4 parameters, and receiving nothing in return. The submitForm Web method receives 2 parameters and returns a string.

Wouldn't you have to assign a value to the Javascript line and check it?
Code:
// Javascript
var result = PageMethods.submitForm(pagewoTable, pagecfTable);
if (result == "success") {
  OnSubmitComplete('') ;
} else {
  OnManuFailed('') ;
}
As well, you may want to return the actual error messages in your C# code instead of just the word failed; again, I'm not 100% familiar with the language, so unless ASP.NET makes the "error" variable globally available, I would suspect you won't have access to it via your Javascript OnManuFailed() function.

Hope this helped ... even a little bit.

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top