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

2012年3月28日水曜日

ResolveUrl equivalent from web service

Hi,I need to resolve a relative URL (eg "~/path/to/file") from within a web service. The only way I know how is using Control.ResolveUrl (or ResolveClientUrl) but obviously neither of these are available from outwith a control context. I've had a look with Reflector at what goes on in those methods and it all uses internal classes so I don't know how I can emulate it.Any ideas? I'm sure theres a method for this somewhere I just need it pointed out!CheersRory

try:

HttpContext.Current.Server.MapPath("~") + "/App_Data/TestFile.jpg", ImageFormat.Jpeg);


Thanks for the reply but I don't see how thats going to help me.

Maybe I wasn't clear enough but I need a Url I can return to the browser. ie From "~/path/to/file" I want to get "/MyApp/path/to/file"


sorry, not much of client side guy myself. I thought you were trying to resolve ~ in a web service to a real path

Resolving <%=MyControl.ClientID%> in a clientside Script which is loaded via ScriptM

Hi experts and developers!

I have a problem using the <%=MyControl.ClientID%> syntax to resolve controls when using clientside script. I really need this functionality though because the control of which i need the clientside id is generated (and dynamically named) by a third party control (DataGrid) I use.

How is it possible to find out the ClientID of a control when the clientside script is loaded via ScriptManager.RegisterClientScriptInclude()?

Thanks for your help in advance!

Greetings,
Wolfgang

hello.

i think i'm not understanding your question very well. MyControl.ClientID gives you the ID of the client...maybe you just need to concatenate it to the rest of the string that is being register as script so that it works...can you show us the code where you're having the problem?


Hi Luis!

Your solution sound absolutely reasonable, but as i use a separate JavaScript File, the <%= %> syntax won't work. And also it does not sound to practicable to change the JavaScript file at runtime (all the time, because the ClientID of the controls changes).

I found a solution already though: I'm just using ClientScript.RegisterArrayDeclaration(MyClientID, myControl.ClientID) on Page_PreRender()... After that I can access the ClientID in my JavaScritp File just via MyClientID[0] as it is a normal js array.

Thanks for the reply!
Wolfgang


hi.

i'd do something like that too if i had the script in a separate file (which is really the recommended approach for script files:))

Response.Redirect

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Deykin:

I have a button on updatePanel, wich has event handler and Response.Redirect in it.

It's not working.

Haw can i resolve this problem.

Thansk

Updatepanel and response.redirect don't work together and they shouldn't either. If you are going to redirect the page to some where else then why even bother to use updatepanel on it for. Updatepanel's purpose is to do partial postback on the same page. Hope that helps.


Actually, Response.Redirect() is supposed to work just fine during async postbacks.

Make sure that you have the ScriptModule registered in your application's web.config file. If it's not, check out the web.config that got installled to your Program Files ASP.NET AJAX folder to see what it should look like.

Thanks,

Eilon


As I recall, someone had the same problem a while ago. It never worked unless ajax implemented it in its lastest version.

Hi

instead of using Response.Redirect try this:

ScriptManager.RegisterClientScriptBlock( lbEditDocument,typeof(LinkButton ),"TestBlock","window.open('"+ redirectUrl +"', '_top');",true );

HTH


I'm with Luis on this one. Response.Redirect has been working fine for me with the RC, and if there's some bug, I'd love to find out before RTM gets out the door.

We could use some more info here, like what exactly is happening when the button is clicked. (I guess it's not doing the redirect, but is it refreshing the page? Is it doing an async postback? What does the traffic look like when you use Fiddler or Nikhil's Web Development Helper?)