Server Error in '/rasmus/liste' Application. --------------------------------------------------------------------------------
Exception of type System.StackOverflowException was thrown. 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.StackOverflowException: Exception of type System.StackOverflowException was thrown.
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:
[StackOverflowException: Exception of type System.StackOverflowException was thrown.]
Fejlen har jeg som sådan fundet ud af. Det er "start" og "slut", der kører i ring... Hvordan løser jeg dette? Ved ikke om det er oplysninger nok... thx
// public int start { get { int dummy = slut; return (_page_length * (_page-1))+1; } } public int slut { get { int _slut = start + _page_length -1; if( _slut > _total_length ) _slut = _total_length; if( _slut == _total_length ) page = (int)Math.Ceiling((double)_total_length / (double)_page_length); return _slut; } } //
I lang tid har samarbejdsbranchen fokuseret på at forbedre enhedsfunktioner – bedre kameraer, klarere lyd og smartere software. Men den virkelige forvandling handler ikke om funktioner.
// using System; using System.Configuration; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Xml;
namespace liste { /// <summary> /// Summary description for _default. /// </summary> public class _default : System.Web.UI.Page { override protected void OnInit(EventArgs e) { int rows_affected = 0; dk.madsb.data.db odb = new dk.madsb.data.db("sql_connection_string"); odb.create_cmd(); System.Xml.XmlDocument xmldoc = odb.get_xml("sp_rasmus_liste_get","root","raekke", ref rows_affected); odb = null;
namespace handy_objekter { /// <summary> /// Summary description for liste. /// </summary> public class liste { private int _total_length = 0; private int _page_length = 0; private int _page = 0;
public liste(int total_length, int page_length, int page) { _total_length = total_length; _page_length = page_length; _page = page; }
public int start { get { int dummy = slut; // <---------- return (_page_length * (_page-1))+1; } } public int slut { get { int _slut = start + _page_length -1; // <-------- if( _slut > _total_length ) _slut = _total_length; if( _slut == _total_length ) page = (int)Math.Ceiling((double)_total_length / (double)_page_length); return _slut; } } // public int total_length { get{ return _total_length; } set{ _total_length = value; } } public int page_length { get{ return _page_length; } set{ _page_length = value; } } public int page { get{ return _page; } set{ _page = value; } } public XmlDocument gi_mig_params() { // XmlDocument xml_params = new XmlDocument(); xml_params.LoadXml("<root/>");
Meningen med denne opgave er, at jeg har en database (liste), som jeg skal kunne trække ud, på forskellige måder i dette dokument. Jeg vil have mulighed for at vælge 5, 10, 15 el. 20 visninger af gangen fra databasen. Problemet er når jeg fjerner denne linie:
//int dummy = slut;
Hvis jeg fx vælger at vise 5 af gangen og bladre frem til side 10(/liste/default.aspx?page=10&page_length=5), og så vil have 20 visninger af gangen, så står jeg med problemet:
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.