Error:System.Web.HttpUnhandledException in Custom Web part for Sandbox solution
Please Help...
I have a sandbox solution for Custom Web part which has a 'Visual Web Part(sandbox)'.
The solution builds, Packages & deploys successfully.
But when adding this custom web part on a Sharepoint 'Web Part Page' it throws up the below Error:
Same code when deployed as a Farm Solution works all well.
Only difference between the two solutions being Farm solution has 'Visual web part'
and Sandbox solution has 'Visual web part(sandbox)'
ERROR:
======================================================
[SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.]
Server stack trace:
at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeAppDomain.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxyForShim.ExecuteInternal(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxy.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
executionContext)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.ExecuteDelegate.EndInvoke(IAsyncResult result)
at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String currentAffinity, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodePoolableProcessConnection.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [1]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(Type userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.<>c__DisplayClassa.b__9()
at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.ExecuteRequestInSandBox(HttpContext context, SPWeb web, SPWebPartManager manager, SPUserCodeWebPart userCodeWebPart)
[HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
Server stack trace:
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.ExecuteHttpRequest(SPUserCodeWebPartHttpRequestContext webPartExecutionContext, SPUserCodeWebPartHttpResponse httpRequestResponse)
at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.Execute(SPUserCodeExecutionContext executionContext)
at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper(SPUserCodeWrapper wrapper, SPUserCodeExecutionContext executionContext)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.CodeToExecuteWrapper.EndInvoke(IAsyncResult result)
at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
executionContext)
[InvalidOperationException: Using Menu.DynamicHoverStyle requires Page.Header to be non-null (e.g. <head runat="server" />).]
at System.Web.UI.WebControls.Menu.EnsureRenderSettings()
at System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Hi!!
Sure, Please find .cs and .ascx script below
==========.ascx===========================
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DynamicMenuWP.ascx.cs" Inherits="MenuWebPartProject.DynamicMenuWP.DynamicMenuWP" %>
<asp:Menu ID="siteStructure" runat="server" Orientation="Horizontal" StaticPopOutImageTextFormatString="" DynamicHoverStyle-BackColor="#CBE3F0" SkipLinkText=""
StaticSubMenuIndent="10px"
BackColor="#000000" CssClass="BIMenu" Font-Names="Verdana" Font-Size="1em" DynamicHorizontalOffset="2" onmenuitemclick="siteStructure_MenuItemClick" Target="_blank">
<StaticSelectedStyle
BackColor="#507CD1" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuStaticformenu" />
<DynamicHoverStyle BackColor="#CBE3F0" />
<DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" ForeColor="Black" />
<DynamicSelectedStyle BackColor="#507CD1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuDynamicForMenu" />
<StaticHoverStyle BackColor="#284E98" ForeColor="White" />
</asp:Menu>
==========.cs===========================
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MenuWebPartProject.DynamicMenuWP
[ToolboxItem(false)]
public partial class DynamicMenuWP : System.Web.UI.WebControls.WebParts.WebPart
protected override void OnInit(EventArgs e)
base.OnInit(e);
InitializeControl();
protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack)
ScorecardStructure ss;
List<ScorecardStructure> listSS = new List<ScorecardStructure>();
using (SPWeb web = SPContext.Current.Web)
SPList lists = web.Lists["MenuItems"];
if (lists.ItemCount > 0)
foreach (SPListItem item in lists.Items)
ss = new ScorecardStructure();
ss.title = Convert.ToString(item["Title"]);
ss.ParentID = Convert.ToInt32(Convert.ToString(item["Parent ID"]));
ss.ParentName = Convert.ToString(item["Parent Name"]);
ss.MenuID = Convert.ToInt32(Convert.ToString(item["Menu ID"]));
ss.menuName = Convert.ToString(item["Menu Name"]);
ss.url = Convert.ToString(item["URL"]);
ss.friendlyName = Convert.ToString(item["Friendly Name"]);
listSS.Add(ss);
if (listSS.Count > 0)
List<ScorecardStructure> y = listSS.Where(s => s.ParentID == 0).ToList<ScorecardStructure>();
foreach (var x in y)
MenuItem newMenuItem = new MenuItem(x.menuName.ToString(), x.MenuID.ToString());
siteStructure.Items.Add(newMenuItem);
AddChildMenuItems(listSS, newMenuItem);
private void AddChildMenuItems(List<ScorecardStructure> menuData, MenuItem parentMenuItem)
if (menuData.Count > 0)
List<ScorecardStructure> childItems = menuData.Where(s => s.ParentID == Convert.ToInt32(parentMenuItem.Value)).ToList<ScorecardStructure>();
foreach (var v in childItems)
MenuItem newMenuItem = new MenuItem(v.menuName.ToString(), v.MenuID.ToString());
newMenuItem.NavigateUrl = v.url.ToString();
parentMenuItem.ChildItems.Add(newMenuItem);
// This code is used to recursively add child menu items filtering by ParentID
AddChildMenuItems(menuData, newMenuItem);
protected void siteStructure_MenuItemClick(object sender, MenuEventArgs e)
string st = e.Item.NavigateUrl;
if (!(st.Equals(string.Empty)))
HttpContext.Current.Response.Redirect(st);
class ScorecardStructure
public string title { get; set; }
public int ParentID { get; set; }
public string ParentName { get; set; }
public int MenuID { get; set; }
public string menuName { get; set; }
public string url { get; set; }
public string friendlyName { get; set; }
public bool IsPostBack { get; set; }
Similar Messages
-
Standard Web Service and Customized Web Services with or without PI?
Hi All,
I want to know how I can use Standard Web Service available in SAP and customized Web Services
without PI Interface?
And what is the best practice to expose services ,via PI Interface or directly?
Thanks in advance!!
PushkarThis is purely based on your requirement. If you use PI middleware to expose web services, you get standard functionalities such as certificate authentication, logging, message reprocessing for the failed messages etc. If your requirement is so simple, then you might not need PI. In this case you can develop simple webdynpro for abap program to create webservice and expose the webservice in ECC webservice runtime. You can let anyone to consume within your network. other ways like exposing BAPI/RFC as webservice. I would recommend going with PI.
-
Dynamically add web part in sandbox solution
I've site in office 365. I want to add site page in /SitePages on feature activation. I also want to dynamically add web part in this site page.
How can I do this?Hi,
According to your description, you might want to add a page into the “Site Pages” library and add a web part into it in the FeatureActivated event in a Sandboxed solution.
To add a site page, you can refer to the two links below:
http://www.c-sharpcorner.com/blogs/4526/programmatically-create-wiki-page-in-sharepoint.aspx
http://sharepoint2010mind.blogspot.ch/2012/06/add-publishing-page-to-sharepoint-site.html
Then add a web part to the page:
http://blog.mastykarz.nl/inconvenient-provisioning-web-parts-wiki-pages-sandboxed-solutions/
Best regards
Patrick Liang
TechNet Community Support -
Hello experts,
I'm totally new to C#. I'm trying to modify existing code to automatically rename a file if exists. I found a solution online as follows:
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
while (allFiles.Contains(tempFileName ))
tempFileName = String.Format("{0} ({1})", fileName, count++);
output = Path.Combine(folderPath, tempFileName );
string fullPath=output + ".xml";
However, it gives the following compilation errors
for the Select and Contain methods respectively.:
'System.Array' does not contain a definition for 'Select' and no extension method 'Select' accepting a first argument of type 'System.Array' could be found
(are you missing a using directive or an assembly reference?)
'System.Array' does not contain a definition for 'Contains' and no extension method 'Contains' accepting a first argument of type 'System.Array' could be
found (are you missing a using directive or an assembly reference?)
I googled on these errors, and people suggested to add using System.Linq;
I did, but the errors persist.
Any help and information is greatly appreciated.
P. S. Here are the using clauses I have:
using System;
using System.Data;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using System.Text;
using System.Linq;Besides your issue with System.Core, you also have a problem with the logic of our code, particularly your variables. It is confusing what your variables represent. You have an infinite loop, so the last section of code is never reached. Take a look
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace consAppFileManipulation
class Program
static void Main(string[] args)
string fullPath = @"c:\temp\trace.log";
string folderPath = @"c:\temp\";
string fileName = "trace.log";
string output = "";
string fileNameOnly = Path.GetFileNameWithoutExtension(fullPath);
string extension = Path.GetExtension(fullPath);
string path = Path.GetDirectoryName(fullPath);
string newFullPath = fullPath;
string[] allFiles = Directory.GetFiles(folderPath).Select(filename => Path.GetFileNameWithoutExtension(filename)).ToArray();
string tempFileName = fileName;
int count = 1;
//THIS IS AN INFINITE LOOP
while (allFiles.Contains(fileNameOnly))
tempFileName = String.Format("{0} ({1})", fileName, count++);
//THIS CODE IS NEVER REACHED
output = Path.Combine(folderPath, tempFileName);
fullPath = output + ".xml";
//string fullPath = output + ".xml";
UML, then code -
WLC Custom Web Auth Bundle sample .tar file is not on WCS
The WLC documentation would make it appear (or maybe previously) you should download a sample web auth bundle code from the WCS Templates. I was never able to find a sample .tar file on the WCS 7.0.172.0 templates.
However I found on Cisco.com under Support > Downloads > Products >Wireless> Wireless LAN Controller Standalone Controllers> Cisco 5500 Series Wireless Controllers > Cisco 5508 Wireless Controller > Wireless Lan Controller Web Authentication Bundle-1.0.2 > webauth_bundle-1.0.2.zip
It was updated in June 2011, some pretty good sample html code.
The readme.html in the sample webauth_bundle-1.0.2.zip file has been very helpful , almost as good as the suppport community web page on custom web auth.
https://supportforums.cisco.com/docs/DOC-13954WCS config guide 7.0.172 is correct
http://www.cisco.com/en/US/docs/wireless/wcs/7.0MR1/configuration/guide/temp.html#wp1129979
The bundle in WCS is downloaded through :
configure->controller
"select a command"-> download customized webauth bundle.
Just tested it and it was there.
The one on cisco.com is better though -
Error - System status CRTD is active
During order settlement following error is appeared
Error - System status CRTD is active.
Pls suggest the solution.Hi ,
1. go to tcode BS22 (Maintain: System Status)
2. look for the system status CRTD.
3. Double click the field "CRTD".
4. in the transaction control tab look for the business transaction "RMWA" or goods movement (you can type it in the lower left corner buttom box bcoz there will ber many entries , and it will be very difficult to find RMWA).
5. select the radio button from "Forbidden" to "allowed".
6. save your changes
Regards,
Anupam
Edited by: Anupam Halder on Aug 3, 2009 11:59 AM -
Customer exit code for fiscalyear period based on system date
Hi Experts,
Please provide customer exit code for fiscalyear period derive based sy-datum. Fiscal year period derivie current to previous 12 periods and current to fast 12 periods.
Thanks,
SubbarajuHi Subbaraju,
Please use below customer exit code for your solution. Please define declarations as per requirement.
When 'ZFPERIOD'.
IF I_STEP = 2.
ztoday = sy-datum.
zfast = sy-datum + 365.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = ztoday
i_periv = 'K4'
IMPORTING
E_BUPER = PERIOD2
E_GJAHR = YEAR2.
CONCATENATE YEAR2 PERIOD2 INTO FISCPERLOW.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = zfast
i_periv = 'K4'
IMPORTING
E_BUPER = PERIOD2
E_GJAHR = YEAR2.
CONCATENATE YEAR2 PERIOD2 INTO FISCPERHI.
L_S_RANGE-LOW = FISCPERLOW.
L_S_RANGE-HIGH = FISCPERHI.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
Similar code user for your previous periods also.
Thanks,
Chandra -
SAP customer number unknown for installation number
Hi There,
We're facing some problems after a reconfiguration of some things in Solution Manager. We have SAP EHP 1 for SAP Solution Manager 7.0. Have made two days ago the installation of the latest SP, but not the kernel yet.
The problem is in the job SEND_SYSTEM_RELATIONSHIP_TO_SUPP. The error is:
08.01.2010 10:43:24 Job started 00 516 S
08.01.2010 10:43:24 Step 001 started (program AI_SC_SEND_SYSTEM_RELATIONSHIP, variant , user ID SOLMAN_BTC) 00 550 S
08.01.2010 10:43:24 SOL determined as monitoring Solution Manager system AI_SC_EN 075 S
08.01.2010 10:43:24 SAP customer number unknown for installation number 00XXXXXXXX AI_SC_EN 097 E
08.01.2010 10:43:24 Job cancelled after system exception ERROR_MESSAGE 00 564 A
The info about the system:
solman:soladm 21> disp+work
disp+work information
kernel release 701
kernel make variant 701_REL
compiled on HP-UX B.11.23 U ia64
compiled for 64 BIT
compilation mode UNICODE
compile time Feb 24 2009 21:53:01
update level 0
patch number 32
source id 0.032
supported environment
database (SAP, table SVERS) 700
701
operating system
HP-UX B.11
Thanks,
JoaoHi João Cesar,
I´m faccing with the same error... I installed the solution manager Ehp1 and it have SPS20 applied which correspond to ST 400 level 20 (SAPKITL430).
When I am in transaction SMSY in section Systems and I press the button "READ SYSTEM NUMBER" is shown an error message that says "SAP customer number unknown for installation" the details of help says:
Diagnosis
Installation number &V1& that is assigned to some system(s) in transaction SMSY is not assigned to an SAP customer number in table AIINSTALLATIONS.
Procedure
Please check the log of background job REFRESH_ADMIN_DATA_FROM_SUPPORT for errors.
So, when I entry in that job log I found this error:
No customer numbers maintained in view V_AISAPCUSTNOS | AI_SC_EN | 106
Then I went in table/view V_AISAPCUSTNOS and inside does not contain any data!!!
All the notes I found were related to lower versions and so I could not implemented the snotes corrections!! Any notes for my release that are related with this problem?
Joao Cesar what you did for solve this problem??? You didn´t mentioned!! You only mentioned that you implemented some notes.. but which ones?!!? -
Error while deploying Sandbox Solution in SharePoint 2010 using Visual Studio
Hi,
I am creating a custom webpart as a sandbox solution.
While deploying I am getting an error
Error occurred in deployment step 'Retract Solution': <nativehr>0x80070005</nativehr><nativestack></nativestack>Access denied.
I have necessary permissions and part of admin group.
Please suggest what could be the issue.Hello,
can you check if your account have access to the SharePoint_Config database? if it's still doesn't work, check if the used account is a local administrator of the machine
Best regards, Christopher.
Blog |
Mail
Please remember to click "Mark As Answer" if a post solves your problem or
"Vote As Helpful" if it was useful. -
How to fix javascript error/bug on custom web part of SharePoint 2013
I have a custom web part with serveral business fields. This web part is installed on DispForm, EditForm an NewForm.
But, I click on Attach File button and a javascrit error is throw on my browser's status bar.
Line: 5279
Character: 5
Code: 0
URI: http://mysite:4000/_layouts/15/form.debug.js?rev=vyMg8qjZfJ8La1jn7bQ2cg%3D%3D
How to solve this problem? I think it is a javascript conflict
Tarcísio Corte [email protected]Hi,
1. You can create a simple demo web part without your custom code firstly, then insert it into your form pages to see if the similar issue would occur. If it works, then add your
other code into it one after one. By doing this, it will be easier to find out the root cause of this issue.
2. What browser do you use? Please try to use IE 10(SharePoint 2013), IE8(SharePoint2010).
3. You can also debug your code using IE F12 Developer Tools.
http://blogs.msdn.com/b/kaevans/archive/2011/04/25/debugging-javascript-with-the-ie-developer-tools.aspx
If the issue still exists, I can suggest you provide more information for further research.
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support -
Export to PDF in Sharepoint Custom web part.
Hi,
I want to export my page to pdf in sharepoint custm web part. I am using below code to export to pdf. when i click the export button i am getting below
Error. how to resolve this error? pLease help me.
Code
protected void ExporttoPDF_Click(object sender, EventArgs e)
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=ExporttoPDF.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
Error
Server Error in '/' Application.
RegisterForEventValidation can only be called during Render();
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called during Render();
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: RegisterForEventValidation can only be called during Render();]
System.Web.UI.ClientScriptManager.RegisterForEventValidation(String uniqueId, String argument) +11081278
System.Web.UI.WebControls.TextBox.AddAttributesToRender(HtmlTextWriter writer) +455
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +27
System.Web.UI.WebControls.TextBox.Render(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +411
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +87
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +53
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +42
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +240
System.Web.UI.Page.Render(HtmlTextWriter writer) +38
Microsoft.SharePoint.WebPartPages.WikiEditPage.Render(HtmlTextWriter writer) +207
PayrollProject.PaySlip4Employee.PaySlip4EmployeeUserControl.btnPDF_Click(Object sender, EventArgs e) +425
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +140
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +29
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2981
Version Information: Microsoft .NET Framework Version:2.0.50727.5472; ASP.NET Version:2.0.50727.5474Hi,
We know that the Page.EnableEventValidation property is set to true(The default is true.), Sharepoint Custom web(ASP.NET Web) validates that a control event originated from the user interface that was rendered by that control. A control registers its
events during rendering and then validates the events during postback or callback handling.
If you write client script freely,you might have to set "EnableEventValidation = false" in your C# code behind,but this method may be troublesome in SharePoint,
so the method of "sadomovalex"( http://sadomovalex.blogspot.in/) is a good idea.
Best Regards -
SP 2013 - Use PowerShell to Add a Custom Web Part to a Page
Hello Community,
I need to add a custom web part to a page using PowerShell - has anyone done this and if so please provide guidance and code examples.
Thanks!
Tom
Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
Linked-In - SharePoint GypsyBTW, here is my current code:
#$web= Get-SPWeb -Identity "http://c4968397007/sites/BRE"
$Url = "http://c4968397007/sites/BRE"
$pageUrl = "/SitePages/Home"
$webpartzone = 2
$index = 0
$fileName = "wp_DistrictHomePage_VisualWebPart1.webpart"
$web = Get-SPWeb $Url
$web.AllowUnsafeUpdates=$true
$webPartGallery = $web.Lists["Web Part Gallery"]
Write-Host "Searching webpart $fileName in web part gallery"
if($webPartGallery -eq $null)
Write-Host("Unable to retrieve Webpartgallery");
$webpart = $null;
$webpart=$webPartGallery.Items | ? { $_.Title -eq $fileName}
if($webpart -eq $null) {
Write-Host("Unable to retrieve webpart: $fileName") -ForegroundColor Red
else {
Write-Host("----------Adding Webpart--------")-ForegroundColor Yellow
$webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$errorMsg = "";
$xmlReader = New-Object System.Xml.XmlTextReader($webpart.File.OpenBinaryStream());
$webpart = $webpartmanager.ImportWebPart($xmlReader,[ref]"Error")
$webpartmanager.AddWebPart($webpart, $webpartzone, $index);
Write-Host("Webpart is added successfully") -ForegroundColor Green ;
$SiteURL =$Url
#---------------Test Page----------------------------
$PageName="Test.aspx"
$page=$web.lists["Pages"].Items | ? {$_.Name -eq $PageName}
$page.File.CheckOut();
Add-WebPartToPage "$SiteURL/Pages/$PageName" "Header" 0 "My Custom WebPart"
$page.File.CheckIn("Added Web part to a page");
$page.File.Approve("Added Web part to a page");
Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
Linked-In - SharePoint Gypsy -
Web Part Error in Sandbox solution
Hi, I used the following code for "ADD POST IN NEWSFEED USING C#" in sandbox solution 2013.
string serverUrl = "http://sanchit:5097/";
string accountName = @"tafecorp\spservices";
SocialDataItem userMentionLink = new SocialDataItem
ItemType = SocialDataItemType.User,
AccountName = accountName
SocialPostCreationData postCreationData = new SocialPostCreationData();
postCreationData.ContentText = "{0} does great work!";
postCreationData.ContentItems = new SocialDataItem[1] { userMentionLink, };
try
ClientContext clientContext = new ClientContext(serverUrl);
SocialFeedManager feedManager = new SocialFeedManager(clientContext);
feedManager.CreatePost(null, postCreationData);
clientContext.ExecuteQuery();
lblReport.Text = "The post was published";
catch (Exception ex)
lblReport.Text = ex.ToString();
When i run the code the following error comes. How to solve this issue. Thanks in advance.
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred. Correlation ID: 5f639c9c-7639-50f3-7dce-34ae387d3ed0.Share the details about correlation ID in ULS logs
http://sharepoint.stackexchange.com/questions/59679/sandbox-unhandled-exception-was-thrown-partial-trust-app-domain
Well it's taken a few days but I've finally managed to work this one out however it did involve me having to dissect the whole project and reintroduce each piece one at a time.
A few issues were causing it:-
1) I had set one of the projects "Include Assembly in Package" property to false.
2) A static method was making a call to an SPList which turned an empty (null) value. Added a value to that item and the error disappeared.
3) I'd declared a variable as being of type double and set its default value as 0.
Now why the system couldn't have told me that's what the problems were rather than throwing this generic error is a different story! It would have saved me many an hour of confusion.
http://stackoverflow.com/questions/3905388/sharepoint-2010-sandboxed-webpart-error
http://social.technet.microsoft.com/Forums/sharepoint/en-US/c11ab5df-562e-43b4-b350-5c4d07da8bf3/sandbox-solution-error-unhandled-exception-was-thrown-by-the-sandboxed-code-wrappers-execute?forum=sharepointgeneralprevious
http://sohilmakwana.wordpress.com/2013/11/29/sandbox-error-unhandled-exception-was-thrown-by-the-sandboxed-code-wrappers-execute-method-in-the-partial-trust-app-domain/
If this helped you resolve your issue, please mark it Answered -
Implementing Exception Handling Application Block in custom web parts, event receivers
hi,
I am currently implementing try {} catch(Exception expp) { throw expp;} to handle exceptions in my intranet appln.
I have several custom web parts, event receivers, few console applciations as timer jobs etc. If i want to implement a robust exception handling what should be the approach. by searching, i saw, ms patterns n practices provides the
appln blocks.
But I think[ pls correct me if i am wrong ] those appln blocks are meant for asp.net applns ONLY.
if not, anyone has implemented those appln blocks in SP development? if yes, can anyone provide one sample / link to implement Exception Handling in SP.
help is appreciated!Hi,
Here are some articles for your reference:
Handling Error Centrally in a SharePoint Application
http://www.codeproject.com/Articles/26236/Handling-Error-Centrally-in-a-SharePoint-Applicati
Using Microsoft Enterprise Library Application Block in SharePoint
http://www.codeproject.com/Articles/21389/Using-Microsoft-Enterprise-Library-Application-Blo
Exception Handling in SharePoint
http://spmatt.wordpress.com/2012/02/01/exception-handling-in-sharepoint/
Best Regards
Dennis Guo
TechNet Community Support -
Create custom web-part page with OOTB page layout using CSOM (Javascript)
Hi,
I need to create a custom webpart page with a OOTB page layout (eg. Header 3 column footer) using JSOM.
I found a link to do this using CSOM: http://spdevlab.com/2013/03/28/creating-wiki-web-part-and-publishing-pages-via-csom-in-sharepoint-2010/
But here i have to copy the page template from 15 hive and store it in a resource file and I am also getting error as "The request message is too big" and to fix this I need to run a powershell script but I need the code to run in SharePoint online
also.
Isn't there a simpler piece of code in which I can enter the name of the page layout(OOTB/Custom) while creating a page in JSOM as we have in SSOM?
Thanks for the help
sunnyHi,
According to your post, my understanding is that you want to create a custom web part page layout template.
There are some articles about how to create the custom web part page layout template, you can refer to them.
http://www.manageprojectsonsharepoint.com/blog/2011/03/14/creating-your-own-web-part-page-layout-template/
http://sandeeppawar.blogspot.com/2012/06/create-custom-web-part-page-template.html
http://doitwithsharepoint.blogspot.com/2011/08/create-web-part-pages-with-custom.html
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support
Maybe you are looking for
-
I am trying to upgrade my graphics card with new drivers
I play the Sims 3 and recently the game started to freeze. I researched and most advised to update my graphics card. To be sure of my graphics card type I ran the Intel System Identification Utility and this is the information it gave me: Graphics
-
How to set target to Play button on begining DVD
Man you dont use this program for a few months and you gotta take a course on it all over again. Ive completely forgotten how to set the PLAY button to activate at the beginning of the DVD. As in I was burning several DVDs and I tested them on my com
-
How to switch SOA-SUITE to another Database?
I have installed 2 SOA environments: for development: soa1 + db1 and for tests: soa2 + db2 but during 2nd environment installation, i make a mistake and now soa2 like soa1 store its data in db1. How i can switch now, which database soa2 should to use
-
Why do I keep getting Messages Agent wants to use the "log in"keychain, and asks for keychain password. How secure is this?
-
I have Mac OS X 10.5.8 instslled on my my iMac and I've got this message using chrome... Chrome no longer supports Mac OS X 10.5 Google Chrome on Mac OS X 10.5 (Leopard) will stop receiving any updates following Chrome 21. This includes new features,