I’m using an ASP.NET application with a web service, and for some reason one of the web service methods gets skipped. I’m sure it’s a fairly simple problem, but it’s had me stumped for over a day. Am I putting the method call in the wrong method, I would assume OnPreRender would handle everything before the page finshes loading. I am fairly confident that the problem is in this area, if I set the form object’s ImageLoc to a URL when it is instantiated it loads in the ASP.NET page just fine.
I don’t think I left out any relevant code, but if you need to see anything else let me know. The form object is just a few properties with get/set so I left it out. Also please note that String parameters will be changed to something else, I am just trying to get the ground work set up.
.aspx.cs :
localhost.MobileFormServices wsMobile = new localhost.MobileFormServices();
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
//Call the web service to pass image URL
wsMobile.NewForm("parameters");
FormImage.ImageUrl = wsMobile.FormProperties().ImageLoc;
}
web service methods:
//new form object instance
private FormLibrary.Form form = new FormLibrary.Form();
//adds the image location to the form object
[WebMethod]
public void NewForm(String parameters)
{
form.ImageLoc = "http://www.prelovac.com/vladimir/wp-content/uploads/2008/03/example.jpg"; //breakpoint here, never hit
}
[WebMethod]
public FormLibrary.Form FormProperties()
{
return this.form;
}
Are you sure web service isn’t called? The call
although uses same object instance on your page calls completely different instance on Web Service side than when method
was called. Because of that
is called on every web service call.
On every web service call new instance of web service handling the call is created.
So in your example.
wsMobile.NewForm(“parameters”) – new FormLibrary.Form is created when instance handling this call is created.
in this call you set form.ImageLoc – but this form is local to that instance
FormImage.ImageUrl = wsMobile.FormProperties().ImageLoc; – again new FormLibrary.Form is created for instance handling this call
you return ImageLoc of new created FormLibrary.Form. Not what you previously set.