find out wether weob control got change by user

A

Anton Stadler

Hello folks,

is there an easy way of finding out wether a user has changed a value of a
webcontrol (eg textbox or checkboxlist).

Thanks

Anton
 
K

Ken Cox [Microsoft MVP]

Hi Anton,

There's a TextChanged event that fires when the text is changed. You can do
stuff inside its handler. Here's a little sample that might get you going.

Let us know if this helps?

Ken
MVP [ASP.NET]


Public Class onchange
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()

End Sub
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

'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
End Sub

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
If viewstate("txtchange") <> "" Then
Label1.Text = viewstate("txtchange")
End If
End Sub

Private Sub TextBox1_TextChanged _
(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles TextBox1.TextChanged
viewstate("txtchange") = "The text was changed at " & _
Now.ToLongTimeString
End Sub
End Class


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="onchange.aspx.vb"
Inherits="p733workev.onchange"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>onchange</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body ms_positioning="FlowLayout">
<form id="Form1" method="post" runat="server">
<p>
<asp:label id="Label1" runat="server"></asp:label></p>
<p>
<asp:textbox id="TextBox1" runat="server"></asp:textbox></p>
<p>
<asp:button id="Button1" runat="server" text="Button"></asp:button></p>
</form>
</body>
</html>


Hello folks,

is there an easy way of finding out wether a user has changed a value of a
webcontrol (eg textbox or checkboxlist).

Thanks

Anton
 
K

Ken Cox [Microsoft MVP]

Not sure what that is, but probably something inserted and used by the VS.NET
designer.


Thank you,

that helped a lot, but what is the purpose of the line

Private designerPlaceholderDeclaration As System.Object


It works without it as well?

thank you



Anton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top