Ads 468x60px

For New Update Use this Link Offer for you


Monday, 1 April 2013

Count the number of times a submit button has been clicked

Count the number of times a submit button has been clicked

Count the number of times a submit button has been clicked

  How i can find the user click on submit button in multipal time

GUI Html Code As Shown Below

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="counter.aspx.cs" Inherits="counter" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
            Text="counter" />
&nbsp; Show Total Click of Particular User
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

From Image as shown below
On Button Click Couter Code Behind 
static int count = 0; 
protected void Button1_Click(object sender, EventArgs e)
        int totalcount = count;
        TextBox1.Text = totalcount.ToString();

Output as shown below

Download sample code attached

How to count character of TextBox in ASP.NET
In this article i will count the how many character in text box enter by the user.
In my previous article i have explained how i can count the total no of click on button by the user. and another article i have explained and provide the full source code for display the total click by the user on button in text box.
Here, we will see how to check number of character has been inserted in the TextBox. A TextBox Which has max length 120 character and we insert a character in TextBox max length will bedisplay 119 characters. When We enter 120 characters in the TextBox that will be the Max length. Drag and drop a TextBox on the page. Select TextBox and press F4 to property window.

Code For java Scripts as shown below

<style type="text/css">


    background-color: #FFFFFF;
            color: #000000;
            background-color: #FFCCCC;
            color: #ff0000;
    <script type="text/javascript">
        function textCounter1(field, maxlimit)
             if (field.value.length > maxlimit)
                field.value = field.value.substring(0, maxlimit);
                document.getElementById('message').className = "invalid";
                document.getElementById('message').className = "valid";


        function textCounter(field, countfield, maxlimit) {

            if (field.value.length > maxlimit) // if too long then trim it!
                field.value = field.value.substring(0, maxlimit);
                countfield.value = maxlimit - field.value.length;


From Html Code Shown Below 

<form  id="form" runat="server">
    <div style="text-align: center">
    <asp:TextBox ID="message" runat="server" name="message" onkeydown="textCounter(this.form.message,this.form.remLen,120)"

        onkeyup="textCounter1(this.form.message, 120)" class="validentry"

        Height="101px" TextMode="MultiLine" Width="228px"></asp:TextBox>

    <br />
    <input name="remLen" size="5" maxlength="5" value="120" />Character is remaing

Output windows as shown below

Download sample code attached

No comments:

Post a Comment



New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result