SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Location
    Olongapo City
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call Server Side Script from AJAX Tab Control

    I have a situation that requires me to call a server side script from when a specific tab is clicked from an AJAX Control Toolkit Tab Container.

    I am trying to collect data from one of the tabs and show a report on the other. I want to bind the report when the user clicks on the tab header of the next tab. Problem is, the tab onclick event handler can only call javascript procedures embeded on the page. What I need is to call a server side script instead of the javascript.

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2008
    Location
    Dublin, Ireland
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ye gotta love Microsoft's "Ajax" controls that have nothing to do with Ajax. Ironically enough one of the options you have here is to actually use ajax to make your call to the server. That or post back the page when that particular tab is clicked.

  3. #3
    SitePoint Member
    Join Date
    Dec 2008
    Location
    Olongapo City
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the post man.

    I figure you're right. I can postback the page and ask OnLoad if the page was posted back, then I can run the server side script I want.

    So how do I postback the page when the tab is clicked?

    On the other hand, I can make use of real AJAX to call my server side script.

    If so, would the coding be the same as the AJAX from classic ASP?

    And now that you mention it... I guess the tab isn't really AJAX at all. Its just javascript... damn, I wish i thought of that.
    Last edited by spolarium7; Dec 4, 2008 at 18:08.

  4. #4
    SitePoint Evangelist
    Join Date
    Apr 2008
    Location
    Dublin, Ireland
    Posts
    461
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spolarium7 View Post
    Thanks man.

    I figure you're right. I can postback the page and ask OnLoad if the page was posted back, then I can run the server side script I want.

    So how do I postback the page when the tab is clicked?

    On the other hand, I can make use of real AJAX to call my server side script. Would the coding be the same as the AJAX from classic ASP?
    I assumed the there would be a tab changed event or something like it but I have no actual knowledge of the tab control so it's just guessing on my part. The ajax side is up to you. You could use the microsoft ajax stuff, whatever you used in asp or even try jquery (recommended).

  5. #5
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You can consume the server side method from JavaScript as well. Two options you have:
    - Use a web service
    - Create a "public" method in the same page class.

    The method would be a WebMethod. You may search online how to exploit that.

  6. #6
    SitePoint Member
    Join Date
    Dec 2008
    Location
    Olongapo City
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to your posts!

    I have dug a little deeper... and guess what?

    1) I figured I can put the Tab Container in an Update Panel
    2) Set the Tab Container's Autopostback to TRUE
    3) consume the postback method of the page to make it work

    An additional in case you're interested:
    You can ask the Tab Container what the Active Tab is and branch out you code from there, to create custom methods per tab.

    Again thanks for the posts!


Bookmarks

Posting Permissions

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