how to Track 'click' event ?

takesoln

Newcomer
Joined
Mar 2, 2004
Messages
18
Location
Chennai
Hi,

I am drawing a textbox when a button is clicked. But, i want this to be done for the first time the user clicks on the button. My code is


Private Sub Cash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cash.Click

Dim txtbox As New TextBox()

txtbox.Width = Unit.Pixel(100)
txtbox.Height = Unit.Pixel(20)

PlaceHolder1.Controls.Add(txtbox)
End Sub



how do i track down the number of times the button has been clicked ?

:o help me out ...
 
Public TimeClicked as Integer

Private Sub Cash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cash.Click

Dim txtbox As New TextBox()

txtbox.Width = Unit.Pixel(100)
txtbox.Height = Unit.Pixel(20)

PlaceHolder1.Controls.Add(txtbox)
TimeClicked = TimeClicked + 1
messagebox.show(TimeClicked)
End Sub
 
This Does not work because, each time the page loads, the valiable will be initialized.

I tried it with a session variable, but that doesn't work either ...

can you suggest something so that the above mentioned textbox will not disappear after the page loads again ?
 
i don't really get your idea.
if you want to record down how many times the users had clicked on it and this record will still kept after restarting the program, you could either use text file, registry or a databases file..

is this what you want??
 
Oh my god!!
you are asking question based on ASP.net.

sorry..
I thought it is in VB.NET. I am not really expert on it Thousand Apologizes
 
Visual Basic:
Private Sub Cash_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cash.Click
 
dim TimeClicked as integer
 
TimeClicked=Session("ClickCount")
Dim txtbox As New TextBox()
 
txtbox.Width = Unit.Pixel(100)
txtbox.Height = Unit.Pixel(20)
 
PlaceHolder1.Controls.Add(txtbox)
TimeClicked = TimeClicked + 1
Session("ClickCount")=TimeClicked
messagebox.show(TimeClicked) 'This won't work in asp.net anyway though
End Sub
 
Hi,

You can create a session variable in global.asax file and on button click can just increment that variable. And keep a check on the count.

regards
dimple
 
I tried what you said plausiblydamp and Dimple...
It works !! but,
the textbox does not persist on some other event i.e. if the page loads again, the textbox disappears( Naturally .. because, the control does not exist ... so if i want to have the control after the page refreshes, what should i do ?

hope you get my point ...
 
Back
Top