1

I have in my code, and extended version of -

string CurrMonth = "Jan";
int rowId = 1;
string MIMO = "";
double JanMITotal = 0.0;
double JanMOTotal = 0.0;
//continued all the way to December

foreach (DataRow dr in dtMIMODetails.Rows) { //dtDetail has about 50 rows
  HtmlTableRow rowDetails = new HtmlTableRow();
  MIMO = dtMIMODetails["MIMO".ToString();
  {
    CurrMonth = "Jan";
    HtmlTableCell cell = new HtmlTableCell();
    cell.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#FFFF99");
    cell.Style.Add(HtmlTextWriterStyle.TextAlign, "center");

    TextBox tb = new TextBox();
    tb.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#FFFF99");
    tb.Style.Add(HtmlTextWriterStyle.TextAlign, "center");
    tb.Style.Add(HtmlTextWriterStyle.FontSize, "small");
    tb.Style.Add(HtmlTextWriterStyle.Width, "40px");
    tb.Style.Add(HtmlTextWriterStyle.Display, "None");
    tb.ID = "tb" + CurrMonth + "_" + MIMO + "_" + "_" + rowID;
    tb.Text = drMIMODetails[CurrMonth].ToString();

    HtmlAnchor htmlanchor = new HtmlAnchor();
    htmlanchor.ID = "ha" + CurrMonth + "_" + MIMO + "_" + rowID;
    htmlanchor.HRef = "#" + htmlanchor.ID;
    htmlanchor.Title = "Click to change value"; //tooltip
    htmlanchor.InnerText = drMIMODetails[CurrMonth].ToString();
    htmlanchor.Attributes.Add("onclick", "handleTextBox('" + CurrMonth + "', '" + MIMO  + "', '" + rowID + "', 'Show')");

    tb.Attributes.Add("onkeyup", "updateMIMOTotals('" + CurrMonth + "', '" + MIMO  + "', '" +  recordID + "','" + rowID + "')");
    tb.Attributes.Add("onblur", "handleTextBox('" + CurrMonth + "', '" + MIMO  + "', '" + rowID + "', 'Hide')");

    FilteredTextBoxExtender ftbe = new FilteredTextBoxExtender();
    ftbe.ID = "ftbe" + CurrMonth + "_" + MIMO + "_" + rowID;
    ftbe.TargetControlID = tb.ID;
    ftbe.FilterType = FilterTypes.Custom | FilterTypes.Numbers;
    ftbe.ValidChars = ".";

    cell.Controls.Add(tb);
    cell.Controls.Add(ftbe);
    cell.Controls.Add(htmlanchor);
    rowDetails.Cells.Add(cell);

    if (MIMO == MOVEINS) {
        JanMITotal = JanMITotal + Convert.ToDouble(drMIMODetails[CurrMonth]);
    }
    else if (MIMO == MOVEOUTS) {
        JanMOTotal = JanMOTotal + Convert.ToDouble(drMIMODetails[CurrMonth]);
    }
  }

  rowId++;
}

which is repeated for 12 months.

There are other values on this form, that when changed causes this loop to be run again, which is fine. I need to reload the values with the result that the other value change causes.

But after making that other change and reloading the page about 4-5 times, I get the dreaded "Stop running script?" error.

Is there a better way? I do have a javascript file that I use and am slightly familiar with jQuery.

2
  • Stop running script has nothing to do with the C# code. It's referring entirely to the JavaScript. Commented Jul 25, 2012 at 17:01
  • But it's not running a script. my onkeyup event updates other elements within the DOM and finishes. I've added breakpoints to insure I'm not in some sort of infinite loop. Commented Jul 25, 2012 at 17:07

2 Answers 2

1

It's happening on one of the events you associated with the cell: onkeyup, onblur or onclick.

Sign up to request clarification or add additional context in comments.

Comments

1

Stop running script indicates an infinite loop I suspect. If you want help with this, you should post the client side code (javascript) you're running.

1 Comment

Well, there are 3 js events that I handle - onclick, onkeyup and onblur for each of the text boxes. I've added breakpoints into the javascript and there aren't any infinite loops.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.