Tuesday, 17 December 2013

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack


Solved : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Reason:
     The Response.End method ends the page execution and shifts the execution to the Application_EndRequest event in the application's event pipeline. The line of code that follows Response.End is not executed.This problem occurs in the Response.Redirect and Server.Transfer methods because both methods call Response.End internally.
Solution: 
For Response.Redirect
Response.Redirect ("nextpageURL.aspx", false);
For Server.Transfer
Use Server.Execute instead of Server.Transfer

Separate characters in a string using SPLIT and ARRAY

The SPLIT will separate the characters using a unique character or symbol like + , . @_ - etc. and store values in the ARRAY.

Example :

protected void buttonname_Click(object sender, EventArgs e)
{
string a = It-is-a-demo;

string[] b = a.split('-');  //It will split the characters after each of this special character underscore -

string split1 = b[0];  //It will be stored using the array
string split2 = b[1];  // is will be stored
string split3 = b[2];  // a will be stored
string split4 = b[3];  // demo will be stored

lbllaststring.Text = split4;  //demo will be displayed in the label
}
back to top