Steve,
Yes.
There are two aspects, one is Page validation and the other is validation of
the control.
I personally prefer to handle page validation with a "Can I Process?" sProc
so I can apply complex validation, that can change with scope creep and I
often don't have access to production WebServers, but do to databases, so I
can adapt my sProc business rules in the sProc's w/out having to rebuild the
project.
Anyway I've digressed....
Control events and validation are done with <asp:RequiredFieldValidator.....
Here's a textbox for entering the user's ID and on keyboard "Enter" posts,
this combined with the setFocus script makes logging in easy....
<asp:textbox id="tbId" onkeydown="if ((event.which && event.which ==
13) ||
(event.keyCode && event.keyCode == 13))
{document.Form1.btnLogin.click();return false;} else return true;"
runat="server" ToolTip="Enter Your Assigned ID" Width="126px"></asp:textbox>
or a more simple textbox....
<asp:textbox id="tbId" runat="server" ToolTip="Enter Your Assigned ID"
Width="126px"></asp:textbox>
<asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server"
ControlToValidate="tbId" Display="Dynamic"
ErrorMessage="You must specify a ID.">*</asp:requiredfieldvalidator>
Here is where the error msg displays, setting the validator to Dynamic
allows the error to hide this lable until re-evaluated.
<asp:Label id="lblInvalidLogin" runat="server" ForeColor="Red"
Visible="False">The ID entered was not valid.</asp:Label>
Regarding your registering a script, here's a call so that the cursor is in
the ID field in the pageLoad event
If Not Page.IsStartupScriptRegistered("LoginFocusScript") Then
Page.RegisterStartupScript("LoginFocusScript", Me.setLoginFocusScript)
HTH
JeffP....
"sklett" <s@s.comwrote in message
news:O2**************@TK2MSFTNGP05.phx.gbl...
>I need to add extensive validation and interaction client scripting to a
web form. I've done some initial searches for "asp.net and client
scripting" and I've found a couple articles that show methods like
"register script block" and what not. None of these methods will do what
I need, I need to add onChange, onClick, etc events to my controls.
For a simple example: How would I pop an alert when a user clicks on a
server textbox control?
Is this possible?
Thanks for any help,
Steve