Hello All, I am developing a site at the moment in asp.net. I am trying to dynamically hide all tables that are on a page. so, I have the page with front end 'asp:table' on (multiple tables on page).
All want to do is 'on page load' hide all the tables on the page. here is my code and the error i get. Any help would be very much appreciated :) I will probably look silly as vb.net is still quite new to me.
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
For Each Table As Table In Page.Controls
Table.Visible = False
Next
End sub
-----------------------------------------
Erorr being generated:
System.InvalidCastException was unhandled by user code
Message=Unable to cast object of type 'ASP.site_master' to type 'System.Web.UI.WebControls.Table'.
Source=App_Web_dyenvmzk
StackTrace:
at Agility.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\aljacobs\My Documents\Import Ocean Freight Resources\NVOCC\Agility_Logistics.aspx.vb:line 7
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: