|
-
Apr 23rd, 2007, 07:28 PM
#1
Thread Starter
Fanatic Member
javascript startupscript
using vs2005 / 2.0
in my save button i have validation.
when user clicks save, validation is checked, and if it fails, it does not postback. user then fixes errors.
then when user clicks save buton again, confirm box appears, ok/cancel,
for confirmation.
i know with startupscript routine, how i can put this confirm into place? a small sample code is nice. thanks you.
-
Apr 24th, 2007, 12:22 AM
#2
Hyperactive Member
Re: javascript startupscript
Well Here No need for StartUpScriptBlock u can directly use then following code..
Call the following JS from OnClientClick Event
like
OnClientClick="return Validate()"
/************JS Function****************/
function Validate()
{
isAllValid = true;
if ---check for Validation
{
isAllValid = false;
}
if (isAllValid == true)
{
var c = confirm("Are you sure ?");
if (c == false)
isAllValid = false;
}
return isAllValid;
}
/****************************/
Or if u want to to do so then
ClientScript.RegisterStartUpScript(Me.GetType(),"scriptConfirm", "---Write down js without Script tag---")
I am using .NET 2010 with Windows 7
-
Apr 24th, 2007, 01:52 AM
#3
Re: javascript startupscript
Hello,
Just my two cents worth, but given that you are using 2005, depending on what sort of validation you are doing, it may be worthwhile looking into the Validation Controls that are available from the ToolBox, i.e.
RequiredFieldValidator
RangeValidator
RegularExpressionValidator
CompareValidator
CustomValidator
ValidationSummary
These can simpl be dragged and dropped on the form, and then "connected" to a control to perform the validation for you.
Hope this helps!
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|