asp.net C# Button_click event and javascript function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Huang

    asp.net C# Button_click event and javascript function

    Hi,

    What I want to do here is in the asp.net C#, when I click a button then some
    sorts of validation will be checked, then it will call a javascript function
    to open another webform. Would someone tell me how to involve the
    javascript function in the C# button_click event?
    Thanks for help.

    Jason


  • fuzzymelon

    #2
    Re: asp.net C# Button_click event and javascript function


    Hi Jason,

    I'm assuming that you are creating your button dynamically (as in
    inside the .cs side of your page). If you are then just add a
    attribute to your button of type "onclick". This means that when .NE
    finally compiles the page sent to the client, you will have you
    'onclick="..?.. ."' in the button tag which can then point to th
    javascript function.

    Just remember that if the button is also your default submit button o
    your form, you will have to "catch" the form submission
    onsubmit="javas cript: return function1()" on form tag) and return th
    appropriate action (true or false).

    Happy coding!
    Fuzzymelon.co

    --
    fuzzymelo
    -----------------------------------------------------------------------
    fuzzymelon's Profile: http://www.msusenet.com/member.php?userid=245
    View this thread: http://www.msusenet.com/t-187055243

    Comment

    Working...