Showing posts with label believe. Show all posts
Showing posts with label believe. Show all posts

Wednesday, March 28, 2012

Profilewebserice path doesnt work under virtual url.

I tried to find a way to replace profilewebservice with my own webservice or class, and then I found a problem. I don;t believe it is happening, but I am not sure what is wrong.

In ATLAS.js, we can find code like

Sys._Profile.WebServicePath = 'ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx';

see the webservicepath is relative. When I go tohttp://mydomain.com/page/home.aspx, and do Sys.Profile.Load, I get this error:

Parser Error Message:The directive 'Page' is unknown.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

looks like it add my virtualpath in, that doesn't sound right?

Well, it looks like your web service .asmx file has an @.Page directive in it... no? Which is wrong, if true. That's how it appears to me from what you've posted, anyway.

the asmx is ATLAS asmx.

It shows where the error happens, the @.Page is in my page.


? you said you replaced the prepackaged asmx with your own in your first post. Maybe if you posted your code, it'd be easier to help you debug it?

Oh, that confused you.

What I tried to say is I tried to find a way to use my asmx, but before I found a solution, I found a bug .

What I put on my page is just like this :

Sys.Profile.set_autoSave(false);
Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.load();

and I got that error, because the test url ishttp://mydomain/page/home.aspx.

It seems the webservice add the page into its webservicepath.

If this is really a bug, I think ATLAS group should fix it. I am not sure why others didn't find it.

Line 1: <%@. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

You can tell from the error message, "ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx " is what ATLAS defined in its js, but the path doesn't have "/" in front of it, I think that is where the problem from.



Have you tried giving it an absolute url just to test it and see if it's not getting hung up on where to start?


Yes, now I am using my own asmx, I set it with absolute path, it works fine under that url - /page/home.aspx
Glad to hear it!

programatically updating a panel using onblur

Ok, this is driving me nuts and I can't believe there's not a way to do this.

Basically I have a user control that dynamically adds text boxes to its control tree at runtime. I have an UpdatePanel control sitting in the top of my user control with a button and a literal control. When the button is clicked it calls a buttonclicked method in the user control that sets the literal to some text and calls the update method on the panel. It all does what it's supposed to do when I click the button and AJAX works just fine.

Now here's the problem, how on Earth do I add an onblur event to the dynamically created text boxes that will either

a) update the panel; or

b) call the buttonclicked method directly; or

c) click the button

I've tried

1txtBox.Attributes.Add("onblur","javascript:__doPostBack('ctl00_contentPlaceHolder_quoteControl_quoteButton','OnClick','');");

And a large number of variations on the above but to no avail. The problem with the above is that I don't necessarily know the full id of the button control at compile time (and even if I did I really, REALLY wouldn't want to hard code it in my class) and if it doesn't find the control then it does a full form postback making the update panel redundant. I understand that I cannot wire in a custom event handler directly to the onblur method (like you can for the text changed) so it has to be client side.

Is there a way to trigger server side events through client side script? I have to get this done even if it involves hand rolling some javascript function that I can call from the onblur attribute to call the event.

I'm a back end business tier coder so any help with the client side would be most gratefully appreciated.

Rick Edwards

Ok, I've discovered a nasty way to do this using the event hi-jacking technique or "hidden button" method found here:

http://www.dotnetjohn.com/articles.aspx?articleid=224

I'd originally shy'd away from this as it's blatantly a hack but having now spent two day researching this I can't find another way of doing it.

Basically I add a hidden button to my update panel on the parent control and wire in the button click method on the parent control code behind. I then raise the event handler in the parent user control and pass this to the child control classes that are part of my control factory. When a textbox control is manufactured by the factory I can then add the oblur attribute and wire in the button click event handler. The button click method is initialised in the parent user control and within it I call the update method for the AJAX panel.

This is great for just updating a single panel from multiple onblur events, the problem now occurs if I want to update different panels from different textbox controls, I suddenly have to start adding hidden buttons all over the place so this is far from an ideal answer.

I've just found an article on asynchronous callback features in .NET2 and it looks like I might be able to roll my own textbox control with an onblur method built in, anyone with any experience of this?

Rick Edwards


Sorry if I'm missing something, but why couldn't you just set AutoPostBack="true" on the TextBox?

Firstly the autopostback event is fired on either tabbing out of the textbox or on pressing enter and not necessarily on loss of focus. Also I don't want to fire a postback event, I actually need to fire a custom event that calls the update method on my update panel and therefore run an asynchronous postback and a partial render. I don't want to rerender the entire form.

Hope that makes sense. I tried the autopostback initially thinking along your lines but it couldn't do what I wanted.

Rick Edwards


Yes, you would be limited to whenever AutoPostBack actually fires. But then it will do an async postback (as long as it's in your UpdatePanel or set as a trigger) and run whatever handler you've set in OnTextChanged. It shouldn't reload the entire page.

If AutoPostBack doesn't do what you want, your hidden button method should work, but I'd use MyButton.ClientID to get the ID so you don't have to hardcode it (which as you said is error-prone).