RadGrid WebUserControl with RadAjaxManager

2 posts, 0 answers
  1. Sam
    Sam avatar
    11 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    I am using radGrid with EditMode = popup and using WebUserControl within EditFormSetting and I am utilizing RadAjaxManager  as described below
    ASPX page

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="W_GridViewClass_Default2" %> 
     
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml">  
    <head runat="server">  
        <title></title>  
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <table style="width:100%;">  
            <tr> 
                <td> 
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
        <Scripts> 
         <asp:ScriptReference Path="~/W_GridViewClass/jquery-1.3.2.min.js" />   
        </Scripts> 
        </telerik:RadScriptManager> 
                </td> 
            </tr> 
            <tr> 
                <td> 
                    <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1" runat="server">  
                    <AjaxSettings> 
                  <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls> 
                  <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                    </UpdatedControls> 
                    </telerik:AjaxSetting> 
                    </AjaxSettings> 
                    </telerik:RadAjaxManager> 
                </td> 
            </tr> 
            <tr> 
                <td> 
                    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"   
                        Skin="Default">  
                           <img id="imgId" alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page,"Telerik.Web.UI.Skins.Default.Ajax.loading2.gif") %>' align="middle"  />Pleaase wait  
                    </telerik:RadAjaxLoadingPanel> 
                </td> 
            </tr> 
            <tr> 
                <td> 
                    &nbsp;</td> 
            </tr> 
            <tr> 
                <td> 
          
            <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None"   
                onneeddatasource="RadGrid1_NeedDataSource" onitemcreated="RadGrid1_ItemCreated">  
    <MasterTableView autogeneratecolumns="False" EditMode="PopUp">  
    <RowIndicatorColumn> 
    <HeaderStyle Width="20px"></HeaderStyle> 
    </RowIndicatorColumn> 
     
    <ExpandCollapseColumn> 
    <HeaderStyle Width="20px"></HeaderStyle> 
    </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
                <ItemTemplate> 
                    <asp:LinkButton runat="server" CausesValidation="false" CommandName="Edit"   
                        Text="Edit"></asp:LinkButton> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridBoundColumn DataField="InstName" HeaderText="InstName"   
                UniqueName="column3">  
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="Address" HeaderText="Address"   
                UniqueName="column1">  
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="City" HeaderText="City"   
                UniqueName="column2">  
            </telerik:GridBoundColumn> 
        </Columns> 
          <EditFormSettings EditFormType="WebUserControl" PopUpSettings-Modal="true" CaptionFormatString="{0}" CaptionDataField="InstName">  
    <PopUpSettings Modal="True" Width="750px"></PopUpSettings> 
            </EditFormSettings> 
    </MasterTableView> 
            </telerik:RadGrid> 
          
                </td> 
            </tr> 
            <tr> 
                <td> 
                    &nbsp;</td> 
            </tr> 
        </table> 
        <div> 
          
        </div> 
        </form> 
    </body> 
    </html> 
     

    User Control ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="W_GridViewClass_WebUserControl" %> 
     
    <div id="divUctrl">  
    <table width="700">  
        <tr> 
            <td> 
                &nbsp;</td> 
            <td> 
                <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">  
                <Scripts> 
                <asp:ScriptReference Path="~/W_GridViewClass/JScript.js" /> 
                </Scripts> 
                </asp:ScriptManagerProxy> 
            </td> 
            <td> 
                &nbsp;</td> 
        </tr> 
        <tr> 
            <td width="100">  
                input one&nbsp;</td> 
            <td width="200">  
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
            </td> 
            <td width="500">  
                &nbsp;</td> 
        </tr> 
        <tr> 
            <td> 
                &nbsp;</td> 
            <td> 
                &nbsp;</td> 
            <td> 
                &nbsp;</td> 
        </tr> 
    </table> 
    </div> 

    aspx.cs
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
     
    public partial class W_GridViewClass_Default2 : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
              
        }  
     
        protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
        {  
            RadGrid1.DataSource = ClassDB.GetInstInfo();  
        }  
        protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl.ascx";  
        }  

    Js file
    $("div [id $='divUctrl']").ready(function() {  
     
        $("* [id $='TextBox1']").change(function() {  
            var test = "";  
        });  
    }); 

    the problem is that the Javascript file is not loaded in other way is not Synchronized when radgrid edit button fired.
    when I Comment out the AjaxSetting for the RadGrid it works fine and javascript.js is loaded and  $("div [id $='divUctrl']").ready() would be fired. and the chenge event for the textbox would fire properly.

     <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls> 
                <%--  <telerik:AjaxUpdatedControl ControlID="RadGrid1" />--%> 
                    </UpdatedControls> 
                    </telerik:AjaxSetting> 
                    </AjaxSettings> 
                    </telerik:RadAjaxManager> 

    any help would really be Appreciated   
  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 03 Feb 2010 Link to this post

    Hello Sam,

    Please review the following help topics which elaborate on using RadAjax in UserControl and executing javascript after AjaxRequest:
    RadAjax and WebUserControls
    Executing custom javascript code after AJAX update

    Greetings,
    Pavlina
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top