Can't Save File Path to User Profile

3 posts, 1 answers
  1. Laurie
    Laurie avatar
    146 posts
    Member since:
    Feb 2007

    Posted 09 Oct 2009 Link to this post

    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.



    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">  
                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;
               = "";
                        tbAvatarFileName.value = imgFileName;
                        pvwImage.src = imageSrc;
               = "none";
                        tbAvatarFileName.value = imgFileName;
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        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" /> 
            <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" /> 

    .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)  
            if (!IsPostBack)  
        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. Answer
    Fiko avatar
    1406 posts

    Posted 14 Oct 2009 Link to this post

    Hi Laurie,

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

    All the best,
    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.
  3. Laurie
    Laurie avatar
    146 posts
    Member since:
    Feb 2007

    Posted 14 Oct 2009 Link to this post

    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.

Back to Top