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:
.cs File:
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 /> |
| <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; |
| } |
| } |
