Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Sandbox WebPart Postback too Large?

$
0
0

Hi guys, I've done some research and it looks like the error I'm running into (when saving the web part properties) is that my post back is too large. 

This is a simple sandbox web part I'm building, which works great until I added the last configuration option which put me over the limit.

Web Part Code (.cs)

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace P.SPS.UI.Web_Parts.jQuery_UI_Accordion_Zone
{
	[ToolboxItemAttribute(false)]
	public class jQuery_UI_Accordion_Zone : WebPart
	{

		#region custom web part properties
		[WebBrowsable(true),
		Category("JQuery Options"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Include jQuery"),
		WebDescription("Check to include reference to jQuery. * Google CDN")]
		public bool includejQuery { get; set; }

		[WebBrowsable(true),
		Category("JQuery Options"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Include jQuery UI"),
		WebDescription("Check to include reference to jQuery UI. * Google CDN")]
		public bool includejQueryUI { get; set; }

		[WebBrowsable(true),
		Category("JQuery Options"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Include jQuery UI CSS"),
		WebDescription("Check to include reference to jQuery UI CSS. * Google CDN")]
		public bool includejQueryUICSS { get; set; }

		[WebBrowsable(true),
		Category("JQuery Options"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Include SPAccordions Script"),
		WebDescription("Check to include the custom spaccordions() jQuery function.")]
		public bool includeSPAccordionsScript { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Width (px)"),
		WebDescription("If set a min and max width will be applied to the tab container. (integer)"),
		DefaultValue(0)]
		public int dataWidth { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Active"),
		WebDescription("Which panel should be open? (integer)"),
		DefaultValue(0)]
		public int dataActive { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Scroll to Top on Activate"),
		WebDescription("When set to true, the accordion will stay in view while switching headers.")]
		public bool dataScrollToTop { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Collapsible"),
		WebDescription("When set to true, the active panel can be closed.")]
		public bool dataCollapsible { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Disabled"),
		WebDescription("If set the accordion will be disabled.")]
		public bool dataDisabled { get; set; }

		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Event"),
		WebDescription("The type of event that the headers should react to activate the panel. (event in quotations and comma seperated)")]
		public string dataEvent { get; set; }

		public enum dataHeightStyleOptions { auto, fill, content }
		[WebBrowsable(true),
		Category("JQuery Accordion() Properties"),
		Personalizable(PersonalizationScope.Shared),
		WebDisplayName("Height Style"),
		WebDescription("Controls the heigh of the accordion widget and each panel.")]
		public dataHeightStyleOptions dataHeightStyle { get; set; }
		#endregion

		protected override void Render(HtmlTextWriter writer)
		{

			if (includejQuery)
			{
				writer.WriteLine("<script src=\"//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>");
			}
			if (includejQueryUI)
			{
				writer.WriteLine("<script src=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js\"></script>");
			}
			if (includejQueryUICSS)
			{
				writer.WriteLine("<script language=\"javascript\">$('head').append('<link rel=\"stylesheet\" href=\"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css\" />');</script>");
			}
			if (includeSPAccordionsScript)
			{
				writer.WriteLine("<script language=\"javascript\">$(document).ready(function(){if((document.getElementById(\"MSOLayout_InDesignMode\").value==1)?false:true){$(\".spaccordions\").spaccordions()}});(function(a){a.fn.spaccordions=function(){var e=a(this).data(),b={active:(e.active)?e.active:0,collapsible:(e.collapsible==1)?true:false,disabled:(e.disabled)?e.disabled:false,heightStyle:(e.heightstyle)?e.heightstyle:\"auto\",event:(e.event)?e.event:\"click\"};if(e.scrolltotop){b.activate=function(g,l){var k;if(l.newHeader.length==1){k=a(l.newHeader[0])}else{k=a(this).find(\".ui-accordion-header\").eq(0)}var i=a(window).height();var o=(a(window).scrollTop()==0)?a(\"#s4-workspace\").scrollTop():a(window).scrollTop();var h=k.height();var j=k.offset().top;var m=a(\"#s4-ribbonrow\").height();var n=j+o-m;console.log(\"elementScrollY \"+j);console.log(\"screenY \"+i);if(j>=m&&j<=i){}else{a(window).scrollTop(n);a(\"#s4-workspace\").scrollTop(n)}}}var f=a(this).parents(\"table\").eq(1);var d=a('<div class=\"accordion\">');if(e.width>0){d.width(e.width)}var c=a(\"\");a(this).parents(\"tr\").eq(1).remove();f.find(\".s4-wpTopTable\").each(function(h){var g=a(this).find(\" > tbody > tr > td\");c=c.add(\"<h3>\"+a(g[0]).find(\".ms-WPTitle\").text().trim()+\"</h3>\");c=c.add(\"<div>\"+a(g[1]).html()+\"</div>\")});d.append(c);f.before(d);f.hide();d.accordion(b);return this}})(jQuery);</script>");
			}

			writer.WriteBeginTag("div");
			writer.WriteAttribute("class", "spaccordions");

			// build custom jquery Accordion() options
			if (!isEmptyorNull(Convert.ToString(dataWidth.ToString())))
			{
				writer.WriteAttribute("data-width", dataWidth.ToString());
			}
			if (!isEmptyorNull(Convert.ToString(dataActive)))
			{
				writer.WriteAttribute("data-active", dataActive.ToString());
			}
			if (!isEmptyorNull(Convert.ToString(dataCollapsible)))
			{
				writer.WriteAttribute("data-collapsible", Convert.ToString(dataCollapsible).ToLower());
			}
			if (!isEmptyorNull(dataDisabled.ToString()))
			{
				writer.WriteAttribute("data-disabled", dataDisabled.ToString());
			}
			if (!isEmptyorNull(dataEvent))
			{
				writer.WriteAttribute("data-event", dataEvent);
			}
			if (!isEmptyorNull(Convert.ToString(dataHeightStyle)))
			{
				writer.WriteAttribute("data-heightstyle", dataHeightStyle.ToString());
			}/*
			if (!isEmptyorNull(Convert.ToString(dataScrollToTop)))
			{
				writer.WriteAttribute("data-scrolltotop", Convert.ToString(dataScrollToTop).ToLower());
			}*/

			writer.Write(HtmlTextWriter.TagRightChar);
			writer.WriteEndTag("div");

			writer.WriteLine("<p>Use the web part properties menu to configure options for <a href=\"http://jqueryui.com/accordion/\" target=\"_blank\">jQuery UI Accordion</a>.</p>");

			base.Render(writer);

		}

		protected void Page_Load(object sender, EventArgs e)
		{

		}


		public bool isEmptyorNull(string value)
		{
			if (string.IsNullOrEmpty(value) || value == "0")
			{
				return true;
			}
			return false;
		}

	}
}

Now can anyone recommend how I could solve this issue? I'm not a back-end programmer :/.

Error after Post:

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.
Show Error Details

Debugger doesn't show anything so I know it wasn't reaching my code.



Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>