Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to navigate from one ASP.NET page to another one (each with a visual webpart) When I click a button on the first page (in my visual webpart of course), I should navigate to the second page. But it seems I cant use Response.Redirect(...) in my c# code of the first visual webpart. Also Server.Transfer cannot be used.

Does anyone know what's wrong? Thanks! (If it isn't possible to use this, is there another way?)

What DOESN'T work:

Response.Redirect("url");
SPUtility.Redirect("url")
HttpContext.Current.Response.Redirect
Server.Transfer

Thanks

share|improve this question
add comment

2 Answers

Yes you are correct. None of the above options work in Sandbox.

I got around this issue by using the JavaScript window.location = "new url" and then pushing it to the page using the ClientScriptManager.RegisterClientScriptBlock method.

http://msdn.microsoft.com/en-us/library/btf44dc9.aspx

share|improve this answer
    
I'll try this later this week, but I think this could work... –  Ruben Herman Feb 24 '12 at 12:04
add comment

try Response.Redirect("your page url");

so, something like this should work for you:

protected void clearBtn_Click(object sender, EventArgs e) { Response.Redirect("your page url"); }

share|improve this answer
1  
I said I can't use this... I guess because I'm in a sandboxed solution –  Ruben Herman Jan 18 '12 at 15:04
    
can you post the code that you currently have? –  ironman99 Jan 18 '12 at 15:05
    
No, because I don't have any. I've only got an empty function. When I try to use Response.Redirect("<my url>"), It doesn't accept the Response.Redirect as valid command –  Ruben Herman Jan 18 '12 at 15:12
    
you can try SPUtility.Redirect() or, HttpContext.Current.Response.Redirect –  ironman99 Jan 18 '12 at 15:17
    
As I thought, Response.Redirect is in the System.Web namespace. I had imported the assembly, namespace already, so I guess this is being blocked by a sandboxed solution –  Ruben Herman Jan 18 '12 at 15:19
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.