Not being a web developer and just getting into it has been quite a change. One thing I am having problems with is retaining information. I want to ask the question is it bad to do something like this: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here strLoginUser = Session("Login") intClientID = Session("ClientID") If Not IsPostBack Then 'bind the grid 'the first time IsPostBack=False (on the initial load) 'because of this we default to open issues Call SetDefaults() End If End Sub
Meaning say strLoginUser was a string of the class and intClientID was an integer of the class. This page load event fires every time this page loads, meaning a user may leave this page (go to another tab) and come back at a later time. When they come back to this tab (page) this event fires again and I store the user name and client identifier via the session variables. Is this a bad idea ? I have noticed at times that the variables are empty after the session timeout of twenty minutes hits...so then my page fails with this huge error message at the top:An Error Occurred: System.Data.SqlClient.SqlException: Procedure 'select_action_items_by_type' expects parameter '@ResponsiblePerson', which was not supplied. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader() at ims.jakah.com._default.BindActionItemsGrid(Int32 intType, Int32 intSortField, String strPerson) in \\Jakah-iis-2\ims\default.aspx.vb:line 223
And I know why it errors out because it calls this function 'BindActionItemsGrid' which passes the user name as a stored procedure parameter. The parameter ends up not getting a value so Im wondering how to handle this. Is this normal ? Because i have used apps in the past that take me back to the login page if my session has timed out. But how do I check for this and redirect back to the login page if my procedure errors out ?Or should I not be doing this this way ?Thanks,