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

Can't Save File Path to User Profile

2 Answers 39 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Laurie
Top achievements
Rank 2
Laurie asked on 09 Oct 2009, 10:15 PM
I'm trying to use the RadFileManager tool to enable the user to display, upload, and set their avatar picture in the profile.  I'm able to get it to display and I set the value of the filename into a textbox (which is working just fine), but when I go to save the information to the profile, it references the original value that was in the textbox.  My code is below.  Please help.

Thanks.

Laurie

ASPX File:
<%@ Page Language="C#" MasterPageFile="~/CFFMFeedback.master" AutoEventWireup="true" CodeFile="ManageProfile.aspx.cs" Inherits="webadmin_ManageProfile" Title="CFFMFeedback Admin: Manage Profile" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<%@ MasterType VirtualPath="~/CFFMFeedback.master" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">  
    <telerik:RadCodeBlock ID="codeBlock1" runat="server">  
        <script type="text/javascript">  
            //<![CDATA[
            function OnClientItemSelected(sender, args)
            {
                var pvwImage = $get("<%= imgAvatar.ClientID %>");
                var tbAvatarFileName = $get("<%= tbAvatar.ClientID %>");
                var imageSrc = args.get_path();
                var imgFileName = args.get_item().get_name();
                if (imageSrc.match(/\.(gif|jpg)$/gi))
                {
                    pvwImage.src = imageSrc;
                    pvwImage.style.display = "";
                    tbAvatarFileName.value = imgFileName;
                }
                else
                {
                    pvwImage.src = imageSrc;
                    pvwImage.style.display = "none";
                    tbAvatarFileName.value = imgFileName;
                }
            }
            //]]> 
        </script> 
    </telerik:RadCodeBlock> 
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
<h2> 
    Manage Profile</h2> 
<p>Please update the information below so it is current.  This information will be displayed in any feedback responses you post.</p> 
Name:<br /> 
<asp:TextBox id="tbName" runat="server" MaxLength="256" Width="400px"></asp:TextBox><br /> 
Position:<br /> 
<asp:TextBox id="tbPosition" runat="server" MaxLength="256" Width="400px"></asp:TextBox><br /> 
Email:<br /> 
<asp:TextBox id="tbEmail" runat="server" MaxLength="256" Width="400px"></asp:TextBox><br /> 
Phone:<br /> 
<asp:TextBox id="tbPhone" runat="server" MaxLength="256" Width="400px"></asp:TextBox><br /> 
Avatar:<br /> 
 
    <table><tr><td><telerik:RadFileExplorer ID="rfeAvatars" runat="server" EnableCreateNewFolder="False" 
        Height="200px" Width="300px" OnClientItemSelected="OnClientItemSelected" VisibleControls="Grid, Toolbar, AddressBox, ContextMenus">  
        <Configuration SearchPatterns="*.*" ViewPaths="~/images/avatars" UploadPaths="~/images/avatars" DeletePaths="~/images/avatars" /> 
    </telerik:RadFileExplorer></td><td> 
        <asp:Image ID="imgAvatar" runat="server" AlternateText="Avatar" style="display:block;  
                        margin: 10px; width: 100px; height: 100px; vertical-align: middle;" /><asp:TextBox ID="tbAvatar" runat="server" MaxLength="256" Width="150px" ReadOnly="true"></asp:TextBox></td></tr></table>  
    <br /> 
    &nbsp;<asp:Button ID="btnSaveProfile" runat="server"   
            Text="Save" OnClick="btnSaveProfile_Click" /> 
</asp:Content> 
 
 

.cs File:
using System;  
using System.Data;  
using System.Configuration;  
using System.Collections;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using System.Web.UI.HtmlControls;  
 
public partial class webadmin_ManageProfile : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        Master.SetMessage("");  
        if (!IsPostBack)  
            BindProfileData();  
    }  
    protected void BindProfileData()  
    {  
        tbName.Text = Profile.Name;  
        tbPosition.Text = Profile.Position;  
        tbEmail.Text = Profile.Email;  
        tbPhone.Text = Profile.Phone;  
        tbAvatar.Text = Profile.AvatarPicFileName;  
        imgAvatar.ImageUrl = "~/images/avatars/" + Profile.AvatarPicFileName;  
        rfeAvatars.ExplorerMode = Telerik.Web.UI.FileExplorer.FileExplorerMode.Default;  
    }  
    protected void btnSaveProfile_Click(object sender, EventArgs e)  
    {  
        Profile.Name = tbName.Text;  
        Profile.Position = tbPosition.Text;  
        Profile.Email = tbEmail.Text;  
        Profile.Phone = tbPhone.Text;  
        Profile.AvatarPicFileName = tbAvatar.Text;  
    }  
}  
 

2 Answers, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 14 Oct 2009, 02:58 PM
Hi Laurie,

Could you please remove the ReadOnly="true" property from the TextBox's declaration and try it again?

All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Laurie
Top achievements
Rank 2
answered on 14 Oct 2009, 03:29 PM
Thanks, that did the trick.  Since I really didn't want them typing into that field, I kept it as readonly and created a hidden field that I also stored the value of the file name into.  I change both of these fields simultaneously when the user clicks on an image and use the hidden field to set my profile.

Thanks again for the help.

Laurie
Tags
FileExplorer
Asked by
Laurie
Top achievements
Rank 2
Answers by
Fiko
Telerik team
Laurie
Top achievements
Rank 2
Share this question
or