Can not call a method that is located outside the AJAX  UpdatePanel

Posted on 2008-02-07
Medium Priority
Last Modified: 2012-08-14
I have AJAX UpdatePanel wrapped around GridView control. When user clicks on the button inside the panel I need to display
message in the Label control that is located outside the UpdatePanel. I need to call method that will show the message.
In a debug mode I placed a breakpoint to the method call it stops there and it seems that partial page rendering does not allow to call methods outside the UpdatePanel. Any suggestions how to call the method from the UpdatePanel:

Here the code snippet:

#region GridView_OnRowCommand methods

    protected void gvUnpostedTransSummary_OnRowCommand(object sender, GridViewCommandEventArgs e)

        if (e.CommandName.Equals("post"))
        {  this.GetTransactionArguments(e.CommandArgument.ToString()); }  

    private void GetTransactionArguments(string rowID)
        int row = -1;
        string agencyID = string.Empty;
        decimal total = 0.0m;
        string userID = string.Empty;

        int.TryParse(rowID as string, out row);

        if (row != -1)
            GridViewRow selectedRow = gvUnpostedTransSummary.Rows[row];

            agencyID = ((Label)selectedRow.FindControl("lblAgencyID")).Text;
            total = Convert.ToDecimal(((Label)selectedRow.FindControl("lblTotal")).Text);
            userID = ((Label)selectedRow.FindControl("lblUserID")).Text;
            string msg = "Unexpected error has occured!Please contact IT Department";
            this.SetInfoMessage(msg,InfoMsgColor.Maroon);   // This method is defined in the code-behind. It never gets called!!!


Please advice!

Question by:alik13
  • 3

Accepted Solution

zkeown earned 2000 total points
ID: 20842211
The label control can't be updated if it's not inside an UpdatePanel.  You could either move it inside the same updatepanel as the gridview or give it its own UpdatePanel and set a trigger to the GridView's RowCommand event.

Author Comment

ID: 20842300
Thank you! I will try it.

Author Comment

ID: 20843850
I decided to give it its own UpdatePanel and set a trigger to the GridView's RowCommand event.

                                    <asp:Label ID="lblInfo" runat="server" Visible="False" Width="290px"></asp:Label>
                                <Triggers >
                                 <ajax:AsyncPostBackTrigger ControlID ="gvUnpostedTransSummary" EventName ="gvUnpostedTransSummary_OnRowCommand" />

but when I click on the form I get the following error message:

"Could not find an event named 'gvUnpostedTransSummary_OnRowCommand' on associated control 'gvUnpostedTransSummary' for the trigger in UpdatePanel 'upInfo'."

Author Comment

ID: 20843992
Never mind guys,  I found the solution.

<Triggers >
        <ajax:AsyncPostBackTrigger ControlID ="gvUnpostedTransSummary" EventName "RowCommand" />      </Triggers>

  Solution:  instead of using EventName ="OnRowCommand" like in the origanal GridView, I need to change it to
        EventName ="RowCommand"

Thank you guys!

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question