I am having a difficult time debugging my assignment. The assignment is due as a single aspx page. My difficulty I believe is partially caused by my inability to properly debug my aspx page in Visual Studios by using breakpoints.
My first question: Is this possible to do?
All of the resources I discovered online have said the solution is to create a separate class file.
Before I go about doing that I just wanted to be sure that there is no other way to go about using breakpoints within a script block.
My next question pertains to the format of an inline script block. My particular confusion relates to the use of global variables. Since it is in a script tag, is there anything different I need to be aware of like when they fall out of scope? If I declare an ArrayList in the global scope of the script and use the Add method on button click, will the result be identical to that of similar code behind?
Here is some simple code to demonstrate my confusion:
<script runat="server">
ArrayList al = new ArrayList();
protected void Button1_Click(object sender, EventArgs e)
{
al.Add(TextBox1.Text);
}
</script>
if it doesnt get fired, please check if Button1 still has the Button1_Click event binded. When you kept playing around with the code, you might have destroyed event binding. Please check ig the event is still binded to the Button1
From KB Article 303247:
ASP.NET supports two methods to author pages:
In-Line Code
In-line code is code that is embedded directly within the ASP.NET page. The following code represents a sample ASP.NET page that includes in-line code:
Myinlinecode.aspx
That example done, if you want/need something to be global, a good thing to use are extra controls in your HTML.
Consider this modified version of MS's code:
Notice the
asp.HiddenField
is used to store data on the HTML page, and it can be accessed later.If you want to see more about this, do a search using "aspx in-line code".
This is a common problem that has been asked a number of times. See
Why can't I debug my asp.net web app
Why can't I debug my asp.net web project anymore?
Why am I unable to Debug my ASP.NET website in Visual Studio?
Unfortuantely, since it can arise from a number of sources, you pretty much have to work through the stack of possible problem resolutions.
There is absolutely no problem debugging code in the ASPX file. I do this all the time.If it will actually compile, then you should be able to set breakpoints within your code. You haven't been clear about exactly what problem you are having?
Regarding your second question, "global" variables exist for the life of the page. But note that the page only exists when it gets loaded. When the page has rendered, it is no longer needed.