2011-09-19 77 views
0

我有一個InfoPath表單,當我點擊按鈕應該重定向到SharePoint列表項的附加項模板..代碼behined我給需要對代碼隱藏邏輯輸入在InfoPath按鈕

try 
{ 
    string url = "Sharepoint List item's URL"; 
    HttpContext.Current.Response.Redirect("url"); 
    } 
    catch 
    { 
    } 

但我收到安全錯誤這樣

System.Security.SecurityException 請求類型的權限「System.Web.AspNetHostingPermission,系統,版本= 2.0.0.0,文化=中性公鑰= b77a5c561934e089」失敗。 在Activity_Profile.FormCode.btnNewReportingUnit_Clicked(對象發件人,ClickedEventArgs E) 在Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent) 在Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

請幫我在這:)

+0

即使在URL字段,如果我給www.google.com我得到相同的錯誤....使用HttpContext.Current.Response.Redirect(「網址」)的問題; – Govind

回答

1

嘗試以下操作:

  • 嘗試使用HttpContext.Current.Response.Redirect("url", false);
  • 請務必參照的文CE System.Web並添加進口聲明它
  • 檢查表單安全設置爲完全信任

我想這與不具有形式充分信任,因此不要做被允許在任何地方重定向。

+0

Moontear我得到的對象引用未設置爲HttpContext.Current.Response.Redirect對象的實例(「url」,false);我已將System.Web和Security添加爲完全信任 – Govind

+0

當您使用變量而不是*「url」*?像myVar.toString()? –

+1

任何方式我使用一些隱藏的文本框來整理問題......感謝您的支持:) – Govind