Cómo limitar los clics en LinkButton

I have some textboxes with linkbuttons. The linkbutton does some updates to some SQL tables.

I also have members club (aspnet membership), and apparently every user has a userid (GUID).

I want to limit the number of clicks to 3 clicks per day on that LinkButton. If they click more than 3 per day, the linkbutton will be disabled.

How can i do that? I don't know from where to start.

preguntado el 08 de noviembre de 11 a las 15:11

2 Respuestas

You'll need to store some sort of counter associated to the user. Cache would probably be the most appropriate place as you can specify an expiration, which you'll need to reset the click count each day.

Algo como esto debería funcionar:

Cache.Insert(base.User.UserID.ToString(), 0, null, DateTime.Today.AddDays(1), System.Web.Caching.Cache.NoSlidingExpiration); 

The above will store the userID in cache until midnight of the next day, and then it will be reset. Each time the user clicks the button, increment the value stored in cache, and once the number of clicks reaches three (3), disable the button.

respondido 08 nov., 11:19

how can i check the "reaches three" and disable the button ? - Oshrib

You can check on the button event handler if the user has already clicked using a cookie.

The cookie will contain date and number of clicks.

respondido 08 nov., 11:19

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.