SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    0 Post(s)
    0 Thread(s)

    Calling JS Function From Code Behind When Button Clicked....


    Basically I have a screen where you can add notes to results and you can optionally add these notes to a table within the database called progress notes!

    However, you should only be allowed to do this if the user that is logged into the page has a note type associated with them and the included in progress notes check box is select on the screen.

    So when the button is pressed I make a call to the database to make sure that the user has a note type, if not a warning dialog needs to be displayed say that they cannot save this note as a progress note if they don't have a note type for their user.

    So far I have done the db calls fine however, however the problem is displaying the modal dialog if the above criteria are not met. Because the user can change the status of the check box as many times as they want once the page is loaded thus I need to call the JS function when the user actually clicks the button instead of using the old fashion way and using the button.Attribute.Add method because this will only work if the page is reloaded.

    So to cut a long story short.... How do I called a JS function directly from a code behind file ....

  2. #2
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Cape Town, South Africa
    48 Post(s)
    0 Thread(s)
    The best way to do this in my opinion, would be to make an ajax call. So on button click make a JS ajax request to another page. eg clickHandler.ashx?vars=here that page does the check and outputs either true or false and the JS does what it needs to from there.

    Althogh this might be a bit of an overkill for you. There is also RegisterClientScript or something like that, but not 100% sure what its called as I never use it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts