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

Accessing controls in rad popup

3 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rajz
Top achievements
Rank 1
Rajz asked on 11 Nov 2010, 07:59 AM
Hello,

We have been using Rad popup and would like to know what are the ways to access the controls in popup such as textbox, lable, dropdowns etc., before the popup is closed.

Example scenario:

Clicking edit button opens a popup window, where the user enters some data and upon clicking Save button, each control is to be validated server side-using cs or client side using/javascript before the popup is closed.

Appropriate message is to be displayed in the popup itself in case of any validation violation

Thank you

Regards
Raj

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2010, 12:00 PM
Hello Raj,

I assume that you are using Editmode "Popup" for RadGrid. Please take a look at the following documentation which explains how to add validator to an edit field in that case.

Adding a validator to an edit field in Telerik RadGrid



In the case of you are using RadWindow control to edit the record, then it is easy to access the controls on that page which is shown in RadWindow. The controls will be directly available on page and you can access those either from client or server in that page.

Thanks,
Princy.
0
Rajz
Top achievements
Rank 1
answered on 11 Nov 2010, 12:38 PM
Hello,

I am sorry, the page is getting javascript error!
or just copy-n-paste the page content to my mail id

Is there any other link available?

Thank you

Regards
Raj
0
Tsvetina
Telerik team
answered on 16 Nov 2010, 02:25 PM
Hi Rajz,

The code provided in the help article for adding a required field validator to an edit form of RadGrid is the following (in case you are editing a bound column):
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if(e.Item is GridEditableItem && e.Item.IsInEditMode)
  {
     GridEditableItem item = e.Item as GridEditableItem;
     GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor( "ContactName");
     TableCell cell = (TableCell)editor.TextBoxControl.Parent;
  
     RequiredFieldValidator validator = new RequiredFieldValidator();
     editor.TextBoxControl.ID = "ID_for_validation";
     validator.ControlToValidate = editor.TextBoxControl.ID;
     validator.ErrorMessage = "*";
     cell.Controls.Add(validator);
  }
}

The sample set up for a template column is:
<telerik:RadGrid id="RadGrid1" runat="server">
  <MasterTableView AutoGenerateColumns="False">
   <Columns>
    <telerik:GridTemplateColumn HeaderText="ContactName" UniqueName="TemplateColumn">
     <EditItemTemplate>
      <asp:TextBox id="TextBox1" runat="server" Text='<%# Bind("ContactName") %>'></asp:TextBox>
      <asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ErrorMessage="*"
       ControlToValidate= "TextBox1"></asp:RequiredFieldValidator>
     </EditItemTemplate>
     <ItemTemplate>
      <asp:Label id="Label1" runat="server" Text='<%# Eval("ContactName") %>'></asp:Label>
     </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
   </Columns>
  </MasterTableView>
 </telerik:RadGrid>

There is other useful information in that article as well, so I advise you that you try to open it again (maybe in a different browser than the previous time). The link in Princy's post is correct and opens the page without any errors on my side.

Sincerely yours,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Rajz
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rajz
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or