This is a migrated thread and some comments may be shown as answers.

Modal Pop up extender

2 Answers 325 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Anjali
Top achievements
Rank 1
Anjali asked on 14 Jul 2011, 10:51 PM
Hi All,

  I am adding comments to the database by opening the modal pop up extender. User can type the comment in the modal pop up text box and as soon as the user clicks Ok button, the comments go to the database, and i pull those saved comments from database and display them in the grid.
Everything works fine except when I put the ajax panel around the Ok button, the display of the saved comments stopped right away. I am not sure what am I doing wrong. Below is my code

<asp:LinkButton ID="lnkComments" runat="server" Text="Add Comments"></asp:LinkButton>
<div>
    <asp:Panel ID="panel1" runat="server" CssClass="modalPopup" Style="display: none"
        Width="500px" BackColor="#E6E6E6">
        <p>
            Please add the comments</p>
        <asp:TextBox ID="txt_comments" runat="server" TextMode="MultiLine" Width="480px"></asp:TextBox>
        <div>
          <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel_Ok" LoadingPanelID="RadAjaxLoadingPanel1">
            <asp:Button ID="OkButton" runat="server" Text="OK" OnClick="OkButton_Click" CommandName="Ok"  />
            <asp:Button ID="CancelButton" runat="server" Text="Cancel" />
            </telerik:RadAjaxPanel>
        </div>
    </asp:Panel>
</div>
<div>
   
    <asp:ModalPopupExtender ID="ModalPopUp_Comments" runat="server" TargetControlID="lnkComments"
        PopupControlID="panel1" BackgroundCssClass="modalBackground" 
        CancelControlID="cancelButton" DropShadow="true">
    </asp:ModalPopupExtender>
          
</div>

and the code behind is

protected void OkButton_Click(object sender, System.EventArgs e)
  {
      ModalPopupExtender ModalPopUp_Comments = (ModalPopupExtender)RadGrid_cDetailsView.MasterTableView.Items[0].FindControl("ModalPopUp_Comments");
      TextBox txt_comments = (TextBox)RadGrid_cDetailsView.MasterTableView.Items[0].FindControl("txt_comments");
      RadGrid RadGrid_cComments =(RadGrid) RadGrid_cDetailsView.MasterTableView.Items[0].FindControl("RadGrid_cComments");
      ModalPopUp_Comments.Hide();
      cComments comments = new cComments();
      CiscHeader cHeader = new CiscHeader();
      cHeader.cId = Request.QueryString["ID"];
      if(txt_comments.Text != "")
      {
              //comments.UserId = HttpContext.Current.User.Identity.Name;
             // for testing purposes only
          comments.UserId = "Anjali";
              comments.UserComment = txt_comments.Text;
      }
      cHeader.AddcComments(comments);
      cScoringCtrl cscoringCtrl = new cScoringCtrl();
      cscoringCtrl.savecComments(cHeader);
      txt_comments.Text = string.Empty;
      cHeader.cComment.Clear();
      cscoringCtrl.getcComments(cHeader);
      RadGrid_cComments_Bind(cHeader, RadGrid_cComments);
   
  }
radGrid_cComments_Bind , refreshes the gris and shows the user comments right away.

Any help will be appreciated.

2 Answers, 1 is accepted

Sort by
0
Accepted
Kevin
Top achievements
Rank 2
answered on 15 Jul 2011, 01:26 PM
Hello Anjali,

Are your grids in RadAjaxPanels as well? If not, that is the problem, you can't update controls that are outside the RadAjaxPanel that is performing the ajax request.

Also, instead of using RadAjaxPanel, I would suggest using RadAjaxManager, so you can set the OK button as the ajax initiator and add the grids in the UpdatedControls collection.

I hope that helps.
0
Anjali
Top achievements
Rank 1
answered on 15 Jul 2011, 06:51 PM
Hi kevin,

Thanks kevin!! now it is working

Unfortunatley, i used the ajax panel to get it to work. Where can I get the example of radAjaxmanager so that i can set the ok button as the ajax initiator.

Thanks.
Tags
Ajax
Asked by
Anjali
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Anjali
Top achievements
Rank 1
Share this question
or