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

Editing Data Issue in RadWindow Popup

1 Answer 83 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ted
Top achievements
Rank 1
Ted asked on 10 Apr 2011, 03:02 PM
Hi, 
    I am having a problem in either editing or inserting data into any controls in the RadWindow. Sometimes it will not allow me to do it at all and sometimes if I hold down the left mouse button while the cursor is hovered over the control and type at the same time I can then edit or insert data. In my codesnippet you can see I am dynamically loading a usercontrol to the PopupPage.aspx but in testing I added the server controls directly to the PopupPage.aspx, thinking that maybe it was the usercontrol causing the issue. But still the same issue persisted, can someone please help me?

Codesnippet:

Default.aspx:
  <asp:ImageButton ID="imgAdd" runat="server" OnClientClick="return ShowRadWindowInsertForm('Edit')"  Visible="true" ToolTip="Add User" ImageUrl="~/Common/Images/add.png" />
<telerik:RadGrid ID="radGrid1" runat="server" AllowPaging="True" AllowSorting="True"
    GridLines="None" AutoGenerateColumns="false" OnNeedDataSource="radGrid1_NeedDataSource" OnPageIndexChanged=" radGrid1_PageIndexChanged" OnSortCommand=" radGrid1_SortCommand" OnItemCommand=" radGrid1_ItemCommand" OnItemDataBound=" radGrid1_ItemDataBound">
    <MasterTableView DataKeyNames="Id">
        <RowIndicatorColumn Visible="False">
            <HeaderStyle Width="20px" />
        </RowIndicatorColumn>
        <ExpandCollapseColumn Resizable="False" Visible="False">
            <HeaderStyle Width="20px" />
        </ExpandCollapseColumn>
        <EditFormSettings>
            <PopUpSettings ScrollBars="None" />
        </EditFormSettings>
        <Columns>
            <telerik:GridTemplateColumn SortExpression="FirstName" HeaderText="Full Name" HeaderButtonType="TextButton"
                UniqueName="FullName">
                <ItemTemplate>
                    <%# Eval("FirstName") + " " + Eval("MiddleInitial") + " " + Eval("LastName") + " " + Eval("Suffix")%>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn SortExpression="BirthDate" HeaderText="Birth Date" HeaderButtonType="TextButton"
                HeaderStyle-Width="75px" DataField="BirthDate" UniqueName="BirthDate" DataFormatString="{0:MM/dd/yyyy}">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="User Information" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    (H): <%# Custom.Converters.ToString(Custom.Converters.ToString(Eval("HomePhone")).PhoneFormat(Custom.PhoneFormat.DASHES))%><br />
                    (C): <%# Custom.Converters.ToString(Custom.Converters.ToString(Eval("CellPhone")).PhoneFormat(Custom.PhoneFormat.DASHES))%><br />
                    Email: <%# Eval("Email")%>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn SortExpression="AddDate" HeaderText="Date Added" HeaderButtonType="TextButton"
                HeaderStyle-Width="75px" DataField="AddDate" UniqueName="AddDate" DataFormatString="{0:MM/dd/yyyy}">
            </telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Action" ItemStyle-Width="50px" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:ImageButton ID="imgEdit" runat="server" ImageUrl="~/Common/Images/pencil.png" CausesValidation="false"
                         />   
                    <asp:ImageButton ID="ibDelete" runat="server" CommandName="Delete" ImageUrl="~/Common/Images/cross.png"
                        CommandArgument='<%#Eval("Id") %>' CausesValidation="false" OnClientClick="return confirm('Are you sure that you want to delete user?');" />
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
  
<telerik:RadWindowManager ID="radWinMng1" runat="server" EnableShadow="true" >
    <Windows>
        <telerik:RadWindow ID="PopupDialog" Behaviors="Close" runat="server" Title="Editing Record" 
            ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" />
    </Windows>
</telerik:RadWindowManager>
  
Default.aspx.cs:
 protected void radGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            //Is it a GridDataItem
            if (e.Item is GridDataItem)
            {
  
                ImageButton editLink = (ImageButton)e.Item.FindControl("imgEdit");
                editLink.OnClientClick = String.Format("return ShowRadWindowEditForm ('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][" Id"], "Edit");
            }
        }
  
  
Common.js:
function ShowRadWindowEditForm (id, clt ) {
    window.radopen("PopupPage.aspx?id=" + id + "&clt=" + clt , clt + "PopupDialog");
    return false;
}
  
function ShowRadWindowInsertForm(clt) {
    window.radopen("PopupPage.aspx?id=0&clt=" + clt, clt + "PopupDialog");
    return false;
}
  
  
PopupPage.aspx:
<form id="form1" runat="server">
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
     <asp:PlaceHolder ID="plControl" runat="server" />
    </form>
PopupPage.aspx.cs:
 protected override void OnInit(EventArgs e)
        {
            //PopupPage.aspx?id=1&clt=AcctAdditionalAuthorizedUserEdit
            LoadUserControl(Request.QueryString["clt"]);
            base.OnInit(e);
        }
  
 protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request.QueryString["clt"])
            {
                case "Edit":
                    Edit ThisCtrl = (Edit)plControl.Controls[0];
                    ThisCtrl.UserId = Common.Converters.ToInt32(Request.QueryString["id"]);
                    break;
            }
        }
  
  
private void LoadUserControl(string controlName)
        {
            string Vpath = string.Format("Controls/{0}.ascx", controlName);
            if (File.Exists(Server.MapPath(Vpath)))
            {
                plControl.Controls.Add(LoadControl(Vpath));
            }
        }
  
Edit.ascx:
<fieldset>
    <legend>Edit Data</legend>
    <table style="width: 100%"
        <tr>
            <td style="width:300px; vertical-align: top;">
                <div>
                    <div class="EditFormLeft REQ">
                        First Name:</div>
                    <div class="EditFormRight">
                        <asp:TextBox ID="txtFirstName" runat="server" TabIndex="6"></asp:TextBox>
                    </div>
                    <div class="Clear">
                    </div>
                    <div class="EditFormLeft">
                        Middle Initial:</div>
                    <div class="EditFormRight">
                        <asp:TextBox ID="txtMiddle" runat="server" Width="20" MaxLength="1" TabIndex="7"></asp:TextBox>
                    </div>
                    <div class="Clear">
                    </div>
                    <div class="EditFormLeft REQ">
                        Last Name:</div>
                    <div class="EditFormRight">
                        <asp:TextBox ID="txtLastName" runat="server" TabIndex="8"></asp:TextBox>
                         <input type="text" name="last-name" id="lastName" />
                    </div>
                    <div class="Clear">
                    </div>
                    <div class="EditFormLeft">
                        Suffix:</div>
                    <div class="EditFormRight">
                        <asp:DropDownList ID="ddlNameSuffix" runat="server" TabIndex="9">
                            <asp:ListItem Text="Select..." Value="-1"></asp:ListItem>
                            <asp:ListItem Text="Junior" Value="Junior"></asp:ListItem>
                            <asp:ListItem Text="Senior." Value="Senior"></asp:ListItem>
                            <asp:ListItem Text="II" Value="II"></asp:ListItem>
                            <asp:ListItem Text="III" Value="III"></asp:ListItem>
                        </asp:DropDownList>
                    </div>
                    <div class="Clear">
                    </div>
                    <div class="EditFormLeft REQ">
                        Birth Date:</div>
                    <div class="EditFormRight">
                        <telerik:RadMaskedTextBox ID="txtBdate" runat="server" Mask="##/##/####" DisplayMask="##/##/####" Width="75px"
                            LabelCssClass="" TextWithLiterals="//" TabIndex="13">
                        </telerik:RadMaskedTextBox>
                    </div>
                </div>
            </td>
            <td style="width: 300px; vertical-align: top;">
                <div class="Clear">
                </div>
                <div class="EditFormLeft REQ">
                    Home Phone:</div>
                <div class="EditFormRight">
                    <telerik:RadMaskedTextBox ID="txtHomePhone" runat="server" SkinID="PhoneBox" TabIndex="11">
                    </telerik:RadMaskedTextBox>
                </div>
                <div class="Clear">
                </div>
                <div class="EditFormLeft REQ">
                    Cell Phone:</div>
                <div class="EditFormRight">
                    <telerik:RadMaskedTextBox ID="txtCellPhone" runat="server" SkinID="PhoneBox" TabIndex="12">
                    </telerik:RadMaskedTextBox>
                </div>
                <div class="Clear">
                </div>
                <div class="EditFormLeft REQ">
                    E-mail Address:</div>
                <div class="EditFormRight">
                    <asp:TextBox ID="txtEmail" runat="server" Width="235" TabIndex="1"></asp:TextBox>
                </div>
                <div class="Clear">
            </td>
        </tr>
    </table>
</fieldset>
  
Edit.ascx.cs:
 public int UserId { get; set; }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData(); 
            }
        }
   
        private void LoadData()
        {
            if (UserId  > 0)
            {
                using (DataClass DC = new DataClass())
                {
                    UserObjectData User = Custom.User.GetUsersById(UserId );
                    txtFirstName.Text = User.FirstName;
                    txtBdate.Text = ArxUtilities.ObjectConverters.ToStringFromDate(User.BirthDate);
                    txtCellPhone.Text = User.CellPhone;
                    txtEmail.Text = User.Email;
                    txtHomePhone.Text = User.HomePhone;
                    txtLastName.Text = User.LastName;
                    txtMiddle.Text = AcctAuthUser.MiddleInitial;
                    ddlNameSuffix.SelectedValue = User.Suffix;
                }
            }
            else
            {
                txtFirstName.Text = string.Empty;
                txtBdate.Text = string.Empty;
                txtCellPhone.Text = string.Empty;
                txtEmail.Text = string.Empty;
                txtHomePhone.Text = string.Empty;
                txtLastName.Text = string.Empty;
                txtMiddle.Text = string.Empty;
                ddlNameSuffix.SelectedIndex = 0;
            }
        }

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 13 Apr 2011, 01:39 PM

Hello Ted,

The only case I was not able to enter values in a field was before I set masks to the RadMaskedTextBox controls (Home phone and Cell phone), but this is an expected behavior for this control. 

One other issue I found was that the last div with class Clear was missing its closing tag, which renders the whole page as invalid XHTML. This is not very likely to cause an issue, yet I fixed it, too.

Please note, that you are opening a window with a name that does not exist in the RadWindowManager's collection, so it inherits the default settings and not the settings you have defined for the PopupDialog window. The actual name you get is EditPopupDialog.

Also, without having your database structure I was not able to test your whole logic (especially the RadGrid). You can find my test project attached and it appears to be working fine on my end in all browsers. If you continue experiencing difficulties please open a support ticket and send us a simple runnable project that displays this behavior, so we can pinpoint the cause.



Greetings,
Marin
the Telerik team

Browse the vast support resources we have to jump start 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
Window
Asked by
Ted
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or