vb.net - ASP.Net - Using variable value in different button click events - VB -


i have multiview 4 views. switch between views use 4 buttons , switch multiview's activeview index relevant view inside click event of each button.

in each view there various controls capture data. there submit button @ bottom of final view write data database.

what want achieve capture time stamp of when user clicks button move each view (which written database). can assign timestamp variable using below code in click event of each of 4 buttons

dim phase1timestamp string = datetime.now.timeofday.tostring() 

the problem is, when come write records database in click event of submit button, cannot see values assigned these time stamp variables.

is there way can pass these variable values submit button click event or there different way can achieve altogether? thanks

the easiest way saving variable session, retrieving it. didn't if asp .net web forms or mvc, give option each. mvc has few different ways can achieve (viewdata, viewbag, tempdata, or directly session). i'm not quite familiar web forms can @ least save session.

web forms

to save session:

httpcontext.current.session("phase1timestamp") = phase1timestamp.tostring() 

to retrieve (you may have cast it, depending on type , vb settings):

dim myvar string = httpcontext.current.session("phase1timestamp") 

mvc

to save session:

session("phase1timestamp") = phase1timestamp.tostring() 

to retrieve it:

dim myvar string = session("phase1timestamp") 

a note mvc: if want work across multiple sessions (i.e., different users or same user multiple tabs open), need append identifier ("phase1timestamp") in case sort of unique identifier.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -