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

error in radupload with ajax

3 Answers 106 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
vinamra
Top achievements
Rank 1
vinamra asked on 29 Oct 2008, 07:22 PM
hi i am having problem in rad upload, i hav placed it in grid template control
when clicking update on the grid javascript error occured : "upload is null"
and nothing works as it use to be, no postback no nothing.


i am using rad controls ajax 2008 Q2
My page code is

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewCategory.ascx.cs" 
    Inherits="Admin_Controls_View_Category" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ Register Src="ViewNews.ascx" TagName="ViewNews" TagPrefix="uc1" %> 
<%@ Register Src="AddCategories.ascx" TagName="AddCategories" TagPrefix="uc2" %> 
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" 
    Width="75px" Transparency="15"
    <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading7.gif") %>' 
        style="border: 0px;" /> 
</telerik:RadAjaxLoadingPanel> 
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" HorizontalAlign="NotSet" 
    LoadingPanelID="RadAjaxLoadingPanel1" OnAjaxRequest="RadAjaxPanel1_AjaxRequest" 
    ClientEvents-OnRequestStart="conditionalPostback"
    <table> 
        <tr> 
            <td style="width: 240px" valign="top"
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" 
                    SelectCommand="SELECT [Id], [ParentId], [Name], [ItemCount] FROM [Category]"
                </asp:SqlDataSource> 
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" 
                    SelectCommand="SELECT [Id], [Name] FROM [Category]"></asp:SqlDataSource> 
                <telerik:RadTreeView ID="RadTreeView1" runat="server" DataFieldID="Id" DataFieldParentID="ParentId" 
                    DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="Id" Skin="Vista" 
                    BorderStyle="None" Style="margin-right: 0px; margin-top: 0px;" Width="204px" 
                    OnNodeClick="RadTreeView1_NodeClick" AllowNodeEditing="True" OnNodeEdit="RadTreeView1_NodeEdit"
                    <CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation> 
                    <ExpandAnimation Duration="100"></ExpandAnimation> 
                </telerik:RadTreeView> 
            </td> 
            <td valign="top"
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>" 
                    DeleteCommand="DELETE FROM [News] WHERE [Id] = @Id" InsertCommand="INSERT INTO [News] (SELECT Title, [Content], Active,NewsDate AS [Date Submitted], FeaturedImg AS [Featured Image],  MetaKeywords AS [Meta Keywords], MetaDesc AS [Meta Description], ViewCount AS [View Count], CategoryId) VALUES (@Title, @Content, @Active, @NewsDate, @FeaturedImg, @MetaKeywords, @MetaDesc, @ViewCount, @CategoryId)" 
                    ProviderName="<%$ ConnectionStrings:ASPNETDBConnectionString1.ProviderName %>" 
                    SelectCommand="SELECT Title, [Content], Active, FeaturedImg AS [Featured Image], NewsDate AS [Date Submitted], MetaKeywords AS [Meta Keywords], MetaDesc AS [Meta Description], ViewCount AS [View Count], Id, CategoryId, [Small Description] FROM News WHERE (CategoryId = @CategoryId) ORDER BY [Date Submitted] DESC" 
                    UpdateCommand="UPDATE News SET Title = @Title, [Content] = @Content, Active = @Active, NewsDate = @NewsDate, FeaturedImg = @FeaturedImg, MetaKeywords = @MetaKeywords, MetaDesc = @MetaDesc, ViewCount = @ViewCount, CategoryId = @CategoryId, [Small Description] = @Small_Description WHERE (Id = @Id)"
                    <SelectParameters> 
                        <asp:Parameter Name="CategoryId" DefaultValue="" ConvertEmptyStringToNull="true" /> 
                    </SelectParameters> 
                    <DeleteParameters> 
                        <asp:Parameter Name="Id" Type="Int32" /> 
                    </DeleteParameters> 
                    <InsertParameters> 
                        <asp:Parameter Name="Title" Type="String" /> 
                        <asp:Parameter Name="Content" Type="String" /> 
                        <asp:Parameter Name="Active" Type="Boolean" /> 
                        <asp:Parameter Name="NewsDate" Type="DateTime" /> 
                        <asp:Parameter Name="FeaturedImg" Type="String" /> 
                        <asp:Parameter Name="MetaKeywords" Type="String" /> 
                        <asp:Parameter Name="MetaDesc" Type="String" /> 
                        <asp:Parameter Name="ViewCount" Type="Int32" /> 
                        <asp:Parameter Name="CategoryId" Type="Int32" /> 
                    </InsertParameters> 
                    <UpdateParameters> 
                        <asp:Parameter Name="Title" Type="String" /> 
                        <asp:Parameter Name="Content" Type="String" /> 
                        <asp:Parameter Name="Active" Type="Boolean" /> 
                        <asp:Parameter Name="NewsDate" Type="DateTime" /> 
                        <asp:Parameter Name="FeaturedImg" Type="String" /> 
                        <asp:Parameter Name="MetaKeywords" Type="String" /> 
                        <asp:Parameter Name="MetaDesc" Type="String" /> 
                        <asp:Parameter Name="ViewCount" Type="Int32" /> 
                        <asp:Parameter Name="CategoryId" Type="Int32" /> 
                        <asp:Parameter Name="Small_Description" /> 
                        <asp:Parameter Name="Id" Type="Int32" /> 
                    </UpdateParameters> 
                </asp:SqlDataSource> 
                <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" DataSourceID="SqlDataSource1" 
                    GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource" Skin="Vista" OnUpdateCommand="RadGrid1_UpdateCommand" 
                    ShowStatusBar="True" AllowAutomaticInserts="True" AllowSorting="True"
                    <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EditMode="EditForms" 
                        CommandItemDisplay="Top"
                        <CommandItemTemplate> 
                            <table width="100%"
                                <tr> 
                                    <td align="left"
                                        <asp:HyperLink ID="AddNewsLinkButton1" runat="server" ImageUrl="~/Admin/App_Themes/AdminGreen/images/AddRecord.gif">Add News</asp:HyperLink> 
                                        <asp:Label ID="Label8" runat="server" Text="Add News" AssociatedControlID="AddNewsLinkButton1"></asp:Label> 
                                        <telerik:RadWindow ID="RadWindow2" runat="server" Modal="True" Width="800" Height="810" 
                                            OpenerElementID="ctl00_ContentPlaceHolder1_ViewCategory1_RadGrid1_ctl00_ctl02_ctl00_AddNewsLinkButton1" 
                                            Animation="Slide" NavigateUrl="../AddNews.aspx" VisibleStatusbar="False" VisibleTitlebar="true" 
                                            Behaviors="Close" KeepInScreenBounds="True" Skin="Telerik" Title="Add News"
                                        </telerik:RadWindow> 
                                        &nbsp; 
                                    </td> 
                                    <td width="40%"
                                    </td> 
                                    <td width="30%" align="right"
                                        <asp:ImageButton ID="btnRefresh" Text="Refresh" ImageUrl="~/Admin/App_Themes/AdminGreen/images/Refresh.gif" 
                                            CommandName="Rebind" runat="server" AlternateText="Refresh"></asp:ImageButton> 
                                        Refresh 
                                    </td> 
                                </tr> 
                            </table> 
                        </CommandItemTemplate> 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px"></HeaderStyle> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <telerik:GridTemplateColumn DataField="Id" SortExpression="Id" UniqueName="ID" EditFormHeaderTextFormat="" 
                                Visible="false"
                                <ItemTemplate> 
                                    <asp:Label ID="LabelIdItem" runat="server" Text='<%# Eval("Id") %>' Visible="false"></asp:Label></ItemTemplate
                                <EditItemTemplate> 
                                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("Id") %>' Visible="false"></asp:Label> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="CategoryId" HeaderText="Category" SortExpression="CategoryId" 
                                UniqueName="CategoryId" Display="false"
                                <EditItemTemplate> 
                                    <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource2" 
                                        DataTextField="Name" DataValueField="Id" SelectedValue='<%# Bind("CategoryId") %>'
                                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                                    </telerik:RadComboBox> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Title" HeaderText="Title" SortExpression="Title" 
                                UniqueName="Title"
                                <EditItemTemplate> 
                                    <telerik:RadTextBox ID="RadTextBox1" runat="server" Skin="Vista" Text='<%# Bind("Title") %>' 
                                        Width="125px"
                                    </telerik:RadTextBox> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Title") %>'></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Featured Image" HeaderText="" EditFormHeaderTextFormat="" 
                                SortExpression="Featured Image" UniqueName="Upload" Display="false"
                                <ItemTemplate> 
                                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("[Featured Image]") %>' /> 
                                </ItemTemplate> 
                                <EditItemTemplate> 
                                    <telerik:RadUpload ID="RadUpload1" runat="server" AllowedFileExtensions=".jpg,.jpeg,.bmp,.gif" 
                                        ControlObjectsVisibility="None" Culture="English (India)" MaxFileInputsCount="1" 
                                        Skin="Telerik" TargetFolder="~/Images/FeaturedImages" Width="197px" Height="53px" 
                                        OverwriteExistingFiles="True"
                                    </telerik:RadUpload> 
                                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Bind("[Featured Image]") %>' /> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Date Submitted" DataType="System.DateTime" 
                                HeaderText="Date Submitted" SortExpression="Date Submitted" UniqueName="Date Submitted"
                                <EditItemTemplate> 
                                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("[Date Submitted]", "{0:D}") %>'></asp:Label> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="Label6" runat="server" Text='<%# Eval("[Date Submitted]", "{0:D}") %>'></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Meta Keywords" HeaderText="Meta Keywords" 
                                SortExpression="Meta Keywords" UniqueName="Meta Keywords" Visible="false"
                                <EditItemTemplate> 
                                    <telerik:RadTextBox ID="RadTextBox2" runat="server" Text='<%# Bind("[Meta Keywords]") %>' 
                                        Width="125px"
                                    </telerik:RadTextBox> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("[Meta Keywords]") %>'></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Meta Description" HeaderText="Meta Description" 
                                SortExpression="Meta Description" UniqueName="Meta Description" Visible="false"
                                <EditItemTemplate> 
                                    <telerik:RadTextBox ID="RadTextBox3" runat="server" Height="54px" Text='<%# Bind("[Meta Description]") %>' 
                                        TextMode="MultiLine" Width="232px"
                                    </telerik:RadTextBox> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("[Meta Description]") %>' Visible="false"></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="View Count" HeaderText="View Count" SortExpression="View Count" 
                                UniqueName="View Count" DataType="System.Int32"
                                <EditItemTemplate> 
                                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("[View Count]", "{0}") %>'></asp:Label> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("[View Count]", "{0}") %>'></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Active" HeaderText="Active" SortExpression="Active" 
                                UniqueName="Active" DataType="System.Boolean"
                                <EditItemTemplate> 
                                    <asp:CheckBox ID="CheckBoxActiveEdit" runat="server" Checked='<%# Bind("Active") %>' /> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:CheckBox ID="CheckBoxActiveItem" runat="server" Checked='<%# Bind("Active") %>' 
                                        AutoPostBack="True" OnCheckedChanged="CheckBoxActiveEdit_CheckedChanged" Text="" /> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Small Description" HeaderText="Small Description" 
                                SortExpression="Small Description" UniqueName="Meta Description" Visible="false"
                                <EditItemTemplate> 
                                    <telerik:RadTextBox ID="RadTextBox4" runat="server" Height="54px" Text='<%# Bind("[Small Description]") %>' 
                                        TextMode="MultiLine" Width="232px"
                                    </telerik:RadTextBox> 
                                </EditItemTemplate> 
                                <ItemTemplate> 
                                    <asp:Label ID="LabelDesc" runat="server" Text='<%# Eval("[Small Description]") %>' 
                                        Visible="false"></asp:Label> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn DataField="Content" HeaderText="Content" SortExpression="Content" 
                                UniqueName="Content" DataType="System.String" Visible="false"
                                <EditItemTemplate> 
                                    <telerik:RadEditor ID="RadEditor1" runat="server" AllowScripts="True" Content='<%# Bind("Content") %>' 
                                        ContentFilters="MakeUrlsAbsolute, FixUlBoldItalic, FixEnclosingP, IECleanAnchors, MozEmStrong, ConvertFontToSpan, ConvertToXhtml, IndentHTMLContent, EncodeScripts" 
                                        Skin="Vista" ToolsFile="Controls/SomeTools.xml"
                                        <Content> 
                                                     
                                        </Content> 
                                    </telerik:RadEditor> 
                                </EditItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridEditCommandColumn> 
                            </telerik:GridEditCommandColumn> 
                            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column"
                            </telerik:GridButtonColumn> 
                        </Columns> 
                        <EditFormSettings> 
                            <EditColumn UniqueName="EditCommandColumn1"
                            </EditColumn> 
                        </EditFormSettings> 
                    </MasterTableView> 
                    <ClientSettings> 
                        <Selecting AllowRowSelect="True" /> 
                    </ClientSettings> 
                    <FilterMenu EnableTheming="True"
                        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                    </FilterMenu> 
                </telerik:RadGrid> 
            </td> 
        </tr> 
    </table> 
</telerik:RadAjaxPanel> 
<br /> 
<asp:LinkButton ID="LinkButtonAddCategory" runat="server">Add Category</asp:LinkButton> 
<telerik:RadWindow ID="RadWindow1" runat="server" OpenerElementID="<%# LinkButtonAddCategory.ClientID %> " 
    VisibleOnPageLoad="false" Animation="FlyIn" Modal="True" NavigateUrl="../AddCategory.aspx" 
    OnClientClose="UpdateTreeView" Width="520" Height="460" Behavior="Close" Skin="Telerik" 
    VisibleStatusbar="False" Title="Add Category"
</telerik:RadWindow> 
 
<script type="text/javascript"
 
    function UpdateTreeView() { 
        //var objAjaxManager = $find("ctl00_ContentPlaceHolder1_ViewCategory1_RadAjaxManager1"); 
 
        $find("ctl00_ContentPlaceHolder1_ViewCategory1_RadAjaxPanel1").ajaxRequest("ctl00_ContentPlaceHolder1_ViewCategory1_RadTreeView1") 
 
    } 
</script> 
 
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server"
 
    <script type="text/javascript"
        //On insert and update buttons click temporarily disables ajax to perform upload actions 
        function conditionalPostback(e, sender) { 
            var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig"); 
            if (sender.EventTarget.match(theRegexp)) { 
                var upload = $find(window['UploadId']); 
                //AJAX is disabled only if file is selected for upload 
                if (upload.getFileInputs()[0].value != "") { 
                    sender.EnableAjax = false
                } 
            } 
        } 
    </script> 
 
</telerik:RadScriptBlock> 
 

3 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 02 Nov 2008, 12:58 PM
Hi Vinamra,

The error message denotes that the JavaScript upload object is not initialized. To my regret the HTML code of the page you sent us is not enough to run the page and help identifying the exact reason for that. Please, check if the window["UploadID"] JavaScript variable is being correctly output from the server.

Kind regards,
Erjan Gavalji
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
vinamra
Top achievements
Rank 1
answered on 02 Nov 2008, 03:44 PM
hi

plz tell how to check window["UploadID"] JavaScript variable is being correctly output from the server.

and what other things i can share with u to rectify this problem.
thanks

0
Erjan Gavalji
Telerik team
answered on 02 Nov 2008, 03:48 PM
Hi Vinamra,

You can check if the window["UploadID"] was output by performing a View Source in the browser.

To help us run the page locally, please, isolate the case in a small WebSite and send it to us via a formal support ticket.

Kind regards,
Erjan Gavalji
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Upload (Obsolete)
Asked by
vinamra
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
vinamra
Top achievements
Rank 1
Share this question
or