alik13
asked on
Can not call a method that is located outside the AJAX UpdatePanel
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_OnR owCommand( object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("pos t"))
{ this.GetTransactionArgumen ts(e.Comma ndArgument .ToString( )); }
}
private void GetTransactionArguments(st ring 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.Row s[row];
agencyID = ((Label)selectedRow.FindCo ntrol("lbl AgencyID") ).Text;
total = Convert.ToDecimal(((Label) selectedRo w.FindCont rol("lblTo tal")).Tex t);
userID = ((Label)selectedRow.FindCo ntrol("lbl UserID")). Text;
}
else
{
string msg = "Unexpected error has occured!Please contact IT Department";
this.SetInfoMessage(msg,In foMsgColor .Maroon); // This method is defined in the code-behind. It never gets called!!!
}
}
#endregion
Please advice!
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_OnR
{
if (e.CommandName.Equals("pos
{ this.GetTransactionArgumen
}
private void GetTransactionArguments(st
{
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.Row
agencyID = ((Label)selectedRow.FindCo
total = Convert.ToDecimal(((Label)
userID = ((Label)selectedRow.FindCo
}
else
{
string msg = "Unexpected error has occured!Please contact IT Department";
this.SetInfoMessage(msg,In
}
}
#endregion
Please advice!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I decided to give it its own UpdatePanel and set a trigger to the GridView's RowCommand event.
<ContentTemplate>
<asp:Label ID="lblInfo" runat="server" Visible="False" Width="290px"></asp:Label>
</ContentTemplate>
<Triggers >
<ajax:AsyncPostBackTrigger ControlID ="gvUnpostedTransSummary" EventName ="gvUnpostedTransSummary_O nRowComman d" />
</Triggers>
</ajax:UpdatePanel>
but when I click on the form I get the following error message:
"Could not find an event named 'gvUnpostedTransSummary_On RowCommand ' on associated control 'gvUnpostedTransSummary' for the trigger in UpdatePanel 'upInfo'."
<ContentTemplate>
<asp:Label ID="lblInfo" runat="server" Visible="False" Width="290px"></asp:Label>
</ContentTemplate>
<Triggers >
<ajax:AsyncPostBackTrigger
</Triggers>
</ajax:UpdatePanel>
but when I click on the form I get the following error message:
"Could not find an event named 'gvUnpostedTransSummary_On
ASKER
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!
<Triggers >
<ajax:AsyncPostBackTrigger
Solution: instead of using EventName ="OnRowCommand" like in the origanal GridView, I need to change it to
EventName ="RowCommand"
Thank you guys!
ASKER