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

[Solved] RadGrid WebUserControl with RadAjaxManager

1 Answer 212 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 02 Feb 2010, 10:22 PM

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   

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 03 Feb 2010, 11:23 AM
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.
Tags
Ajax
Asked by
Sam
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or