ASP NET and javascript - urgent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • johnlim20088
    New Member
    • Jan 2007
    • 74

    ASP NET and javascript - urgent

    Hi...


    I have a Javascript function in my test.aspx as follow:-

    <script language="Javas cript">

    function confirm_save()
    {
    if (confirm("Are you sure you want to save this changed?")==tru e)
    return true;
    else
    return false;
    }

    </script>


    I have a Edit, Save, Cancel command on my datagrid, when click Save, -> OnUpdateCommand ="save_data" ,

    the save_data function located in test.aspx.cs, code behind,

    I don't want directly save my data, I plan to insert the javascript function above to the save_data function, so I need to call the javascript from code behind



    Example: In test.aspx.cs

    I have a function

    public void save_data(){

    ------------ CAN I CALL A JAVASCRIPT HERE?

    }


    anyone please help
  • ashasprabhu
    New Member
    • Jan 2007
    • 52

    #2
    hi,
    use the below code in the pageload event
    Dim button As WebControl
    button = Page.findContro l("btnsave")
    button.Attribut es.Add("onclick ", "return confirm_save (this.form);")

    in the javascript
    function confirm_save (frm)
    {
    return confirm ('Are you sure you want to Save the record?')
    }

    Comment

    • johnlim20088
      New Member
      • Jan 2007
      • 74

      #3
      But this is a button in edit template datagrid

      save and cancel only appear after edit button clicked on datagrid..

      where can find a save and cancel button name?

      this is not a link button, or web button


      Originally posted by ashasprabhu
      hi,
      use the below code in the pageload event
      Dim button As WebControl
      button = Page.findContro l("btnsave")
      button.Attribut es.Add("onclick ", "return confirm_save (this.form);")

      in the javascript
      function confirm_save (frm)
      {
      return confirm ('Are you sure you want to Save the record?')
      }

      Comment

      Working...