Having an issue with my button click event. I needed to add this button from one page to another so naturally it was copied and variables changed out within the click event method to match the new page. in the HTML side I added the button there too (stating in case someone wonders if I forgot that part).
Everything is identical to the other page... The issue is... when I try to run it to test the button I get a build error with no errors being displayed. One time I managed to get an error that stated "Handles clause requires a WithEvents variable defined in the containing type or one of its base types." So I commented out the handles portion of the method and it runs yay! except... the button doesn't work. I have tried a few suggestions that stated to restart the IDE, and where someone also mentioned to comment out the handles portion. Is there something I am missing?
<tr>
<td style="width: 209px" valign="middle" align="left"></td>
<td style="width: 7px;" valign="middle"></td>
<td valign="bottom" align="left">
<br>
<asp:Button ID="btnSaveAsExcel" runat="server" Width="264px" Text="Export to Excel"></asp:Button>
</td>
<td valign="middle" align="left"></td>
</tr>
Private Sub btnSaveAsExcel_Click(sender As Object, e As EventArgs) Handles btnSaveAsExcel.Click
If dgFacilitySummary.Visible Then
Dim DummydgFacilitySummary As New DataGrid
DummydgFacilitySummary.DataSource = Session("dsFacilitySummary").tables(0)
DummydgFacilitySummary.DataBind()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & "Faci+lity Summary Report" & ".xls")
HttpContext.Current.Response.Charset = ""
EnableViewState = False
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
DummydgFacilitySummary.RenderControl(hw)
HttpContext.Current.Response.Write(sw.ToString())
HttpContext.Current.Response.End()
ElseIf dgFacilities.Visible Then
Dim DummydgFacilities As New DataGrid
DummydgFacilities.DataSource = Session("dsFacilityMatches").tables(0)
DummydgFacilities.DataBind()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & "Facility Summary Report" & ".xls")
HttpContext.Current.Response.Charset = ""
EnableViewState = False
Dim sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
DummydgFacilities.RenderControl(hw)
HttpContext.Current.Response.Write(sw.ToString())
HttpContext.Current.Response.End()
End If
End Sub
both of that is exactly how it is on another page and it works there.