0

I am trying to debug some code in my code behind files for as aspx page. I have debug set to true both in the page and in my web.config.

Can someone tell me why a) the breakpoint never fires even though the dropdown gets filled and b) why when i uncomment the msgbox it never fires and the dropdown does NOT fill.

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

    If IsPostBack Then
        ddlCity.Items.Clear()
        Dim context As New enerteckEntities()

        'Dim query = context.DistinctCityFromZiptax(Convert.ToInt16(ddlState.SelectedValue))
        Dim query = From c In context.ziptaxes Where c.StateID = ddlState.SelectedValue Order By c.City Select c.City, c.ZipTaxId
        'MsgBox(query.Distinct().ToList())

        ddlCity.DataSource = query.Distinct().ToList()
        ddlCity.DataValueField = "ziptaxid"
        ddlCity.DataTextField = "City"
        ddlCity.DataBind()
    End If
End Sub
dinotom
  • 4,990
  • 16
  • 71
  • 139
  • have you built your solution? ie. Do you have a Play button or a stop button displayed in Visual Studio? – Curtis Sep 12 '12 at 15:59

2 Answers2

0

To hit a break point visual studio has to attach to the process hosting the aspx page.

This is typically done in a Web Application Project by pressing the F5 key or clicking on the "Debug" menu and clicking "Start Debugging".

sclarson
  • 4,362
  • 3
  • 32
  • 44
0

Well based on your code, you will only execute this after a PostBack and not on initial Page Load.

MsgBox will never show up because this is not a WinForms application! You cannot use that in a web.application. If you want you can use Response.Write() or just add a dummy Label to your page and set the text property temporarily. It is the same effect.

The easiest would be to just debug it. Make sure your breakpoints are full Red dots, and you must be in Debug mode. If you are trying to debug from IIS then you must attach to process. If you are using IIS7 (I am assuming you are) then you must go to: Debug Menu > Attach to Process > Find the process named "w3wp.exe" and double click on it. You are now attached.

If your breakpoints are not full red dots after starting debug, then your compiled code and your debug files do not match. Do a Rebuild as opposed to a Build. Beyond that you might be having a funky problem, you can try deleting your obj and bin folders (make sure to save any third party dlls first).

dyslexicanaboko
  • 4,215
  • 2
  • 37
  • 43
  • a)msgbox's do display from asp code behinds but i will try the label method. I am not using IIS I am using development server. – dinotom Sep 12 '12 at 18:13
  • I'm shocked to hear that! I will have to try that myself for amusement, but on a serious note avoid doing it otherwise you might get a bogus error one day from your server side that says something like, "cannot execute because no one is around to press okay" - I don't remember the exact error, it happened to me a few times by mistake. I left message boxes in a library I was debugging. Give this a shot: http://stackoverflow.com/questions/9720143/asp-net-web-application-message-box it might work for you. – dyslexicanaboko Sep 14 '12 at 16:20