Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
294 views
I have a RadGrid that sits within a RadPanel on a RadMultiPage attached to a RadTabStrip :) Was that confusing enough?

I'm trying to implement a RadUpload on the RadGrid. I have followed example in the demo and added the JavaScript for the RadPanel to turn off Ajax on the postback.

I don't receive any errors, however, the file does not upload. Upon doing some testing on why this was occurring, I discovered that after clicking Insert on the grid edit form, my UploadedFiles.Count was zero. I can't seem to figure out why this is happening, but think it may be the way I'm calling my RadUpload in the code behind.

Here is my .aspx page

<%@ Page Language="VB" Debug="true" MasterPageFile="~/eis.master" AutoEventWireup="false" CodeFile="request.aspx.vb" Inherits="request" title="Enterprise Information Systems" %> 
<%@ MasterType VirtualPath="~/eis.master" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="content" runat="Server"
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" /> 
 
<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> 
 
<div class="titleLeft"
    <asp:Label ID="gridCountLabel" CssClass="titleSectionLeft" Text="Request # " runat="server" /><asp:Label ID="requestNo" CssClass="titleSectionLeftHighlight" runat="server" /> 
</div> 
<div class="titleRight"
    <asp:Button class="button" ID="save_btn" Text="Save" runat="server" /> 
    <asp:Button class="button" ID="delete_btn" Text="Delete" runat="server" /> 
    <asp:Button class="button" ID="new_btn" Text="New" runat="server" /> 
</div> 
<div class="clear"></div> 
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
    <AjaxSettings> 
        <telerik:AjaxSetting AjaxControlID="RadMultiPage1"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadMultiPage1" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="RadMultiPage2"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="RadMultiPage2" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="CommentsGrid"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="CommentsGrid" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
        <telerik:AjaxSetting AjaxControlID="AttachmentsGrid"
            <UpdatedControls> 
                <telerik:AjaxUpdatedControl ControlID="AttachmentsGrid" LoadingPanelID="RadAjaxLoadingPanel1" /> 
            </UpdatedControls> 
        </telerik:AjaxSetting> 
    </AjaxSettings> 
</telerik:RadAjaxManager> 
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Width="75px" Transparency="25"
    <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading7.gif") %>' style="border:0; margin-top:90px;" /> 
</telerik:RadAjaxLoadingPanel> 
<div style="min-width:950px; padding-top:10px;"
    <telerik:RadTabStrip id="RadTabStrip1" runat="server" skin="Telerik" SelectedIndex="0" MultiPageID="RadMultiPage1" Width="950"
        <Tabs> 
            <telerik:RadTab ImageUrl="images/icon_package.gif" Text="Request" /> 
            <telerik:RadTab ImageUrl="images/icon_tasks.gif" Text="Tasks" /> 
            <telerik:RadTab ImageUrl="images/icon_savings.gif" Text="LOE/Savings" /> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <div class="MultiPage" style="min-height:400px;"
        <telerik:RadMultiPage ID="RadMultiPage1" SelectedIndex="0" runat="server"
            <telerik:RadPageView ID="PageView1" runat="server">Request 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="PageView2" runat="server">Tasks 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="PageView3" runat="server">LOE/Savings 
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
    </div> 
</div> 
<div style="min-width:950px; border-right:1px solid #dad9d8; border-left:1px solid #dad9d8; border-bottom:1px solid #dad9d8; margin-top:-1px;"
    <telerik:RadTabStrip id="RadTabStrip2" runat="server" skin="Telerik" SelectedIndex="0" MultiPageID="RadMultiPage2" Width="950"
        <Tabs> 
            <telerik:RadTab ImageUrl="images/icon_comments.gif" Text="Comments" /> 
            <telerik:RadTab ImageUrl="images/icon_attachment.gif" Text="Attachments" /> 
            <telerik:RadTab ImageUrl="images/icon_history.gif" Text="History" /> 
            <telerik:RadTab ImageUrl="images/icon_time.gif" Text="Time Tracking" /> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <div class="MultiPage2" style="min-height:50px;"
        <telerik:RadMultiPage ID="RadMultiPage2" SelectedIndex="0" runat="server"
            <telerik:RadPageView ID="PageView4" runat="server"
                <div style="min-width:950px;"
                    <telerik:RadGrid ID="CommentsGrid" 
                        Skin="Telerik" 
                        EnableAjax="false" 
                        EnableLinqExpressions="false" 
                        AllowSorting="true" 
                        PageSize="3" 
                        ShowHeader="false" 
                        ShowFooter="true" 
                        AllowPaging="true" 
                        ShowGroupPanel="false" 
                        GroupingEnabled="false" 
                        OnNeedDataSource="CommentsGrid_NeedDataSource" 
                        OnInsertCommand="CommentsGrid_InsertCommand" 
                        OnUpdateCommand="CommentsGrid_UpdateCommand" 
                        OnDeleteCommand="CommentsGrid_DeleteCommand" 
                        ItemStyle-VerticalAlign="top" 
                        AlternatingItemStyle-VerticalAlign="top" 
                        runat="server"
                        <MasterTableView Name="master" CommandItemDisplay="Top" DataKeyNames="comment_id" Width="100%" HorizontalAlign="NotSet" AutoGenerateColumns="False" AllowSorting="true" GroupsDefaultExpanded="false" HierarchyLoadMode="ServerOnDemand" HierarchyDefaultExpanded="false" NoMasterRecordsText="There are no comments"
                            <CommandItemSettings AddNewRecordText="Add a Comment" RefreshText="Refresh" /> 
                            <Columns> 
                                <telerik:GridBoundColumn UniqueName="comment_id" DataField="comment_id" AllowFiltering="true" Visible="false" /> 
                                <telerik:GridTemplateColumn HeaderText="Comment Date" UniqueName="comment_date" SortExpression="comment_date" Groupable="false"
                                    <ItemTemplate> 
                                        <img src="images/icon_user.gif" alt="" style="vertical-align:middle;" />&nbsp;<asp:Label runat="server" ID="lbl_comment_name" Text='<%# Eval("comment_name") %>' />&nbsp;<span class="small">(<asp:Label runat="server" ID="lbl_comment_date" Text='<%# Eval("comment_date") %>' />)</span> | <asp:LinkButton ID="btnEdit" CssClass="gridLinkButton" Text="Edit" CommandName="Edit" runat="server" />&nbsp;<asp:LinkButton CssClass="gridLinkButton" ID="btnDelete" Text="Delete" CommandName="Delete" OnClientClick="javascript:return confirm('Delete this comment?')" runat="server" /><br /> 
                                        <asp:Label runat="server" ID="lbl_comment_text" Text='<%# Eval("comment_text") %>' /> 
                                    </ItemTemplate> 
                                </telerik:GridTemplateColumn> 
                            </Columns> 
                            <EditFormSettings EditFormType="Template"
                                <FormTemplate> 
                                    <div class="GridEditForm"
                                        <div class="PageContentTitle">Edit Comment</div> 
                                        <div class="PageContentTextFields"
                                            <asp:TextBox ID="tb_comment_text" BorderStyle="solid" BorderWidth="1px" BorderColor="gray" runat="server" Width="100%" Rows="7" TextMode="MultiLine" Text='<%# Bind("comment_text") %>' /> 
                                        </div> 
                                        <div class="PageContentButtons"
                                            <asp:ImageButton ID="btnUpdate" BorderWidth="0" style="vertical-align:middle;" ImageUrl='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "images/grid/Insert.gif", "images/grid/Update.gif") %>' runat="server" CommandName='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>' />&nbsp;<asp:LinkButton CssClass="gridLinkButton" style="font:bold 14px Arial;" ID="linkbtnUpdate" Text='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "Insert", "Update") %>' runat="server" CommandName='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>' />&nbsp;<asp:ImageButton ID="btnCancel" BorderWidth="0" style="vertical-align:middle;" ImageUrl="images/grid/Cancel.gif" runat="server" CausesValidation="false" CommandName="Cancel" />&nbsp;<asp:LinkButton CssClass="gridLinkButton" style="font:bold 14px Arial;" id="linkbtnCancel" Text="Cancel" CommandName="Cancel" runat="server" /> 
                                        </div> 
                                    </div> 
                                </FormTemplate> 
                            </EditFormSettings> 
                        </MasterTableView> 
                        <ClientSettings AllowDragToGroup="True" AllowGroupExpandCollapse="True"
                            <Selecting AllowRowSelect="True" /> 
                            <Scrolling AllowScroll="false" UseStaticHeaders="True" /> 
                        </ClientSettings> 
                        <PagerStyle Mode="NextPrevAndNumeric" /> 
                    </telerik:RadGrid> 
                </div> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="PageView5" runat="server"
                <telerik:radajaxpanel id="RadAjaxPanel1" runat="server" clientevents-onrequeststart="conditionalPostback"
                <div style="min-width:950px;"
                    <telerik:RadGrid ID="AttachmentsGrid" 
                        Skin="Telerik" 
                        EnableAjax="false" 
                        EnableLinqExpressions="false" 
                        AllowSorting="true" 
                        PageSize="3" 
                        ShowHeader="false" 
                        ShowFooter="true" 
                        AllowPaging="true" 
                        ShowGroupPanel="false" 
                        GroupingEnabled="false" 
                        OnNeedDataSource="AttachmentsGrid_NeedDataSource" 
                        OnInsertCommand="AttachmentsGrid_InsertCommand" 
                        OnDeleteCommand="AttachmentsGrid_DeleteCommand" 
                        OnItemDataBound="AttachmentsGrid_ItemDataBound" 
                        ItemStyle-VerticalAlign="top" 
                        AlternatingItemStyle-VerticalAlign="top" 
                        runat="server"
                        <MasterTableView Name="master" CommandItemDisplay="Top" DataKeyNames="attachment_id" Width="100%" HorizontalAlign="NotSet" AutoGenerateColumns="False" AllowSorting="true" GroupsDefaultExpanded="false" HierarchyLoadMode="ServerOnDemand" HierarchyDefaultExpanded="false" NoMasterRecordsText="There are no attachments"
                            <CommandItemSettings AddNewRecordText="Add an Attachment" RefreshText="Refresh" /> 
                            <Columns> 
                                <telerik:GridBoundColumn UniqueName="attachment_id" DataField="attachment_id" AllowFiltering="true" Visible="false" /> 
                            </Columns> 
                            <EditFormSettings EditFormType="Template"
                                <FormTemplate> 
                                    <div class="GridEditForm"
                                        <div class="PageContentTextFields"
                                            <telerik:radprogressmanager id="RadProgressManager1" runat="server" /> 
                                            <telerik:RadUpload ID="RadUpload1" skin="Telerik" InitialFileInputsCount="1" ControlObjectsVisibility="None" runat="server" /> 
                                        </div> 
                                        <div class="PageContentButtons"
                                            <asp:ImageButton ID="btnUpdate" BorderWidth="0" style="vertical-align:middle;" ImageUrl='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "images/grid/Insert.gif", "images/grid/Update.gif") %>' runat="server" CommandName='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>' />&nbsp;<asp:LinkButton CssClass="gridLinkButton" style="font:bold 14px Arial;" ID="linkbtnUpdate" Text='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "Insert", "Update") %>' runat="server" CommandName='<%# IIf(DataBinder.Eval(Container, "OwnerTableView.IsItemInserted"), "PerformInsert", "Update") %>' />&nbsp;<asp:ImageButton ID="btnCancel" BorderWidth="0" style="vertical-align:middle;" ImageUrl="images/grid/Cancel.gif" runat="server" CausesValidation="false" CommandName="Cancel" />&nbsp;<asp:LinkButton CssClass="gridLinkButton" style="font:bold 14px Arial;" id="linkbtnCancel" Text="Cancel" CommandName="Cancel" runat="server" /> 
                                        </div> 
                                    </div> 
                                </FormTemplate> 
                            </EditFormSettings> 
                        </MasterTableView> 
                        <ClientSettings AllowDragToGroup="True" AllowGroupExpandCollapse="True"
                            <Selecting AllowRowSelect="True" /> 
                            <Scrolling AllowScroll="false" UseStaticHeaders="True" /> 
                        </ClientSettings> 
                        <PagerStyle Mode="NextPrevAndNumeric" /> 
                    </telerik:RadGrid> 
                </div> 
                </telerik:radajaxpanel> 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="PageView6" runat="server">History 
            </telerik:RadPageView> 
            <telerik:RadPageView ID="PageView7" runat="server">Time Tracking 
            </telerik:RadPageView> 
        </telerik:RadMultiPage> 
    </div> 
</div> 
 
</asp:Content> 

and here is the sub that handles the Insert Command and the ItemDataBound event
    Protected Sub AttachmentsGrid_InsertCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) 
        Dim filename As String = "" 
        Dim uploader As RadUpload = TryCast(e.Item.FindControl("RadUpload1"), RadUpload) 
        Dim targetFolder As String = Server.MapPath("~/attachments"
        Dim imageFile As UploadedFile = Nothing 
         
        If uploader.UploadedFiles.Count > 0 Then 
            imageFile = uploader.UploadedFiles(0) 
            filename = imageFile.GetName() 
            imageFile.SaveAs(Path.Combine(targetFolder, request_id & "_" & filename), True
 
            Dim sql As String = "" 
            sql = "INSERT INTO [tAttachments] ([user_id],[attachment_date],[request_id],[filename]) VALUES(" 
            sql += Session("sUserID") & ", " 
            sql += "#" & DateTime.Now & "#, " 
            sql += request_id & ", " 
            sql += "'" & filename & "') " 
             
            Try 
                Dim connstr As String = ConfigurationManager.ConnectionStrings("LocalSqlServer").ToString 
                Dim dbconn As New OleDb.OleDbConnection(connstr) 
                dbconn.Open() 
                Dim cmd As OleDb.OleDbCommand 
                cmd = New OleDb.OleDbCommand(sql, dbconn) 
                cmd.ExecuteNonQuery() 
                dbconn.Close() 
            Catch ex As Exception 
                AttachmentsGrid.Controls.Add(New LiteralControl("Unable to add Attachment. Reason: " + ex.Message)) 
                e.Canceled = True 
            End Try 
        End If 
    End Sub 
 
    Protected Sub AttachmentsGrid_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) 
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then 
            Dim upload As RadUpload = TryCast(e.Item.FindControl("RadUpload1"), RadUpload) 
            RadAjaxPanel1.ResponseScripts.Add(String.Format("window['UploadId'] = '{0}';", upload.ClientID)) 
        End If 
    End Sub 

Do I need to call RadUpload1 in a different way? Is that why my file count is coming back as zero?

Any help is greatly appreciated. Thanks.
Philip Senechal
Top achievements
Rank 1
 answered on 14 Dec 2009
2 answers
188 views
I just ran the latest update (Dec. 8th) and now I have an error with Visual Studio Extensions, which have ceased to function.

The message is: Could not load file or assembly 'Telerik.VSX.Controls, Version=2009.2.1009.804...."

I am not familiar enough with the extensions to even begin to look for a missing file or update a web.config file.
Tomica
Top achievements
Rank 2
 answered on 14 Dec 2009
4 answers
168 views
Hi,

This may sound odd but when I assign a OnCommand handler to a RadGrid, either in the code behind or declaratively, the default no record template is not shown when I bind to an empty data source.  I tried a few other ClientSettings, none of them caused the same issue.

My RadGrid is nothing special. Here is one I can reproduce the issue with.

<rad:RadGrid ID="ReasonsGrid" EnableAjax="true" runat="server" Skin="Default" GridLines="None" 
        AllowAutomaticUpdates="False" AllowMultiRowEdit="False" DataSourceID="ReasonsDataSource"
        <ClientSettings> 
            <ClientEvents OnCommand="Grid_OnCommandHandler" /> 
        </ClientSettings> 
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="Applicationreasonid"
            <Columns> 
                <rad:GridBoundColumn DataField="ReasonTypeString" HeaderText="Type" SortExpression="Type" 
                    UniqueName="Type" Visible="True" ReadOnly="true"
                </rad:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
    </rad:RadGrid> 


Any Ideas?
Dean Wyant
Top achievements
Rank 1
 answered on 14 Dec 2009
1 answer
144 views
Hello in my project i m using radgrid with sunset theme, now the problem is when data is in ODD count(1,3,5...)
there is not show proper grid here i attached the screen shot of that issue

Dimo
Telerik team
 answered on 14 Dec 2009
3 answers
175 views

Version: RadControls for ASP.NET AJAX 2009 Q3 (1208)

I have been unable to refresh a listbox after renaming an item using the following code.  I have also attempted using the listbox track/commit functions pre/post rename to no avail.

var listbox = $find("<%= MyListBox.ClientID %>");         
var selectedItem = listbox.get_selectedItem();  
if (selectedItem) {  
 selectedItem.set_text("New Name");  
 listbox.repaint();  

Please suggest the correct method for renaming a listbox item so that it may be visible to the end user.

Thanks,
Karlin
Roby Kaufman
Top achievements
Rank 1
 answered on 14 Dec 2009
3 answers
193 views
Hi,

I'd like to know if I can update the Resource Header width without making every column in the scheduler a larger size?

Have tried the "RowHeaderWidth" option, giving the following result (see attached)...

Edit: May be a bug - doesn't work in IE 8 compatibility mode but does in IE8 standard. Doesn't work in IE6 (needs to work in IE6), works in firefox. Any workaround possible?

Cheers,

Paul
T. Tsonev
Telerik team
 answered on 14 Dec 2009
2 answers
145 views
Hi guys,

Quite hard to explain, but I will try ...

We have in one of our projects a really strange bug. We drag'n'drop a dock to a zone, we "close" it (close for us means move the dock to a specific zone, with a different state ... so instead of close, I should use move). Once done, we can click on the dock titlebar, so the dock moves to its last position.

The bad news is that we have no idea where it comes from, and it is quite hard to understand !
The good news is that the bug is easy to reproduce on the online demo, and I got the good idea to make a video  : http://www.youtube.com/watch?v=zUVYzm_rh00

Any ideas ? Real bug or bad usage of the client-side API ?

Note : bug visible on Firefox 3.5 for sure, sometimes (to be defined) on internet explorer (unknown for other browsers)
Link to the demo : http://demos.telerik.com/aspnet-ajax/dock/examples/clientsideapi/defaultcs.aspx
Laurent
Top achievements
Rank 1
 answered on 14 Dec 2009
8 answers
220 views
Hello,

Is there a way I can set the default ExpandAnimation duration setting globally or in the Skin file without having to update every RadComboBox in my application?  Any help here would be appreciated.

Thanks,
Jeremy
Tobias
Top achievements
Rank 1
 answered on 14 Dec 2009
6 answers
199 views
Hi,

I'm using SPContentProvider class and RadFileExlorer which shows data from Document Library. I wanna disable the redirect (which shows path ".../Forms/Standard.aspx?RootFolder=...") that occurrs when a user makes double click on a directory. How can I achieve this?

I tried following code but without success:

function ClientItemSelected(oExplorer, args) {
  var item = args.get_item();
  if (item.isDirectory()) {  
   args.set_cancel(true);
  }

 }


Thank you!

Fiko
Telerik team
 answered on 14 Dec 2009
1 answer
95 views
Hi,

I need to persist the items selected in my grid across pages . I did this with an arraylist and it works fine.

I use an arraylist, store it in session and retrieve the values. I use an itemcommand event which gets fired when row is being clicked .

But what event gets fired when i select the header checkbox? is there any server side or client side event which gets genertaed.

B'coz when i select the header check box, all the items in mygrid gets selcted. But why the item commnad does not get fired. Pls help me with code samples.

How do i persist these items selcted when header checkbox is selcted and store them also in arraylist.
Schlurk
Top achievements
Rank 2
 answered on 14 Dec 2009
Narrow your results
Selected tags
Tags
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?