Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 ...

Posted

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

George C.K. Low

Posted

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 ?

Posted

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??

George C.K. Low

  • Administrators
Posted
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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

Posted

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 ...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...