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

ModalPopUpExtender and Edit Form

1 Answer 104 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 02 Feb 2009, 08:49 PM
Greetings,

I have a grid with edit mode set to EditForm.  In the form template, I have a template with a button.  When the user clicks the button, I'd like to launch a modal popup using the ModalPopupExtender.

To do this, I have to have the TargetControlId of the button.  The button is created at runtime. 

Any ideas on how to dynamically find the button or launch the popup?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2009, 06:13 AM
Hi Alan,

I have implemented this on my end as shown below. Just give a try with this and see if it is helpful.

ASPX:
    <EditFormSettings EditFormType="template" > 
                   
                        <EditColumn UniqueName="EditCommandColumn1"
                        </EditColumn> 
                        <FormTemplate> 
                         
                         <table runat="server" id="table1"
                           <tr> 
                             <td> 
                              
                             </td> 
                               <td> 
                               <cc1:ModalPopupExtender ID="ModalPopupExtender1"   BackgroundCssClass="modalBackground"  OkControlID="LinkButton2"  CancelControlID="LinkButton3"  PopupControlID="Panel1" runat="server"   > 
                               </cc1:ModalPopupExtender> 
                               <asp:Panel ID="Panel1" runat="server" > 
                              
                                  This is the Pop up text  
                                <asp:LinkButton ID="LinkButton2" runat="server">Ok</asp:LinkButton> 
                                <asp:LinkButton ID="LinkButton3" runat="server">Cancel</asp:LinkButton> 
                              </asp:Panel> 
                               </td> 
                                
                           </tr> 
                         </table> 
                             
                     </FormTemplate> 
                    </EditFormSettings> 

CS:
  protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
        { 
           GridEditFormItem editform = (GridEditFormItem)e.Item; 
           Button btn = new Button(); 
 
            //to add the button to the EditForm 
           HtmlTable table = (HtmlTable)editform.FindControl("table1"); 
           table.Controls[0].Controls[0].Controls.Clear(); 
           table.Controls[0].Controls[0].Controls.Add(btn); 
           btn.ID = "ButtonShow"
           btn.Text = "ShowPopup"
 
           //to  dynamically set the TargetControlID 
           ModalPopupExtender modalpop = (ModalPopupExtender)editform.FindControl("ModalPopupExtender1"); 
           modalpop.TargetControlID = "ButtonShow"
 
        } 
    } 


Regards
Shinu
Tags
Grid
Asked by
Alan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or