HTML is: <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="OneClickTester.WebForm1"%> <%@ Register TagPrefix="mboc" Namespace="MetaBuilders.WebControls" Assembly="MetaBuilders.WebControls.OneClick" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <title>WebForm1</title> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"> <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server" onsubmit="if (document.forms[0].submitted.value == '1') {alert ('You cannot resubmit the form');return false; } else { document.forms[0].submitted.value = '1';return true;}"> <asp:button id="Button1" runat="server" Text="Button" EnableViewState="true"></asp:button><asp:label id="Result" runat="server" EnableViewState="False"></asp:label><mboc:oneclick id="OneClick2" runat="server"></mboc:oneclick><INPUT id="submitted" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 56px" type="hidden" value="0" runat="server"></form> </body> </HTML> code behind is: Imports System.Data Imports System.Data.SqlClient Public Class WebForm1 Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection ' 'SqlConnection1 ' Me.SqlConnection1.ConnectionString = "workstation id=SUNIL;packet size=4096;integrated security=SSPI;data source=""sunil" & _ "\vsdotnet"";persist security info=False;initial catalog=EchoTangoDB" End Sub Protected WithEvents Button1 As System.Web.UI.WebControls.Button Protected WithEvents Result As System.Web.UI.WebControls.Label Protected WithEvents OneClick2 As MetaBuilders.WebControls.OneClick Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection Protected WithEvents submitted As System.Web.UI.HtmlControls.HtmlInputHidden 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here Me.submitted.Value = "0" If IsPostBack Then If OneClick2.IsValid Then Session("TimesSubmitted") = CType(Session("TimesSubmitted"), Integer) + 1 System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10)) Dim cmd As New SqlCommand("Update Table1 SET clicked = " + CStr(CType(Session("TimesSubmitted"), Integer)), Me.SqlConnection1) Me.SqlConnection1.Open() cmd.ExecuteNonQuery() Me.SqlConnection1.Close() End If Else Session("TimesSubmitted") = 0 End If Result.Text = "Operation Completed Successfully " + CStr(Session("TimesSubmitted")) End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click End Sub End Class sun21170 |