Results 1 to 3 of 3

Thread: javascript startupscript

  1. #1

    Thread Starter
    Fanatic Member ZeBula8's Avatar
    Join Date
    Oct 2002
    Posts
    548

    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.

  2. #2
    Hyperactive Member Coool's Avatar
    Join Date
    Feb 2006
    Location
    System.Coool
    Posts
    333

    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

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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
  •  



Click Here to Expand Forum to Full Width