CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2009
    Posts
    27

    Page Method question

    Dear experts,

    I have a javascript function that is called on tab change of a tab container. From that javascript function, I call a simple page method. But though the page method does everything correctly, a failure is reported.
    Here is my code:
    function JSSetMarketingActiveTabIndexSession(sender, args) {
    if (sender != null) {
    PageMethods.SetSessionVariable("MarketingActiveTabIndex", sender.get_activeTabIndex(), OnSucceeded, OnFailed);
    }
    }

    [System.Web.Services.WebMethod]
    public static void SetSessionVariable(string sessionVariableName, object value)
    {
    HttpContext.Current.Session[sessionVariableName] = value;
    }

    When I place breakpoints in the page method and in the OnFailed function, the execution stops in both of them almost at the same time, so an exception is caught even before the page method has done anything.
    Could you please help me on this?
    Thanks.

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Page Method question

    When I place breakpoints in the page method and in the OnFailed function
    Well i dont see either of these two posted in your short code snip ...

    BTW.. Please use code tags .. [code] your code here [/code]
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Aug 2009
    Posts
    27

    Re: Page Method question

    Quote Originally Posted by GremlinSA View Post
    Well i dont see either of these two posted in your short code snip
    My page method is this:

    Code:
     
    [System.Web.Services.WebMethod]
    public static void SetSessionVariable(string sessionVariableName, object value)
    {
    HttpContext.Current.Session[sessionVariableName] = value;
    }
    On Failed():

    Code:
            function OnFailed(exception) {
                if (exception != null) {
                    var tabInformation = $get('<%# Page.Form.FindControl("tcInformation").ClientID %>').control;
                    tabInformation.set_activeTabIndex(2);       
                         
                    lblExceptionDetails = document.getElementById('<%# lblExceptionDetails.ClientID %>');
                    if (lblExceptionDetails != null) {
                        lblExceptionDetails.innerHTML = exception._message;
                        return false;
                    }
                }
            }

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Page Method question

    I've looked over the code and done a few test's and cant find anything wrong.. I'm guessing that you have other code that is run either at 'pageload' or a controls 'onload' event that is failing...

    check all the controls if they have an onload event and what code is running there...
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  5. #5
    Join Date
    Aug 2009
    Posts
    27

    Re: Page Method question

    Thank you anyway.

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

Featured