Hi,
I want display all image after upload, i like use upload silverlight . All step:
1- Upload
2- Generate thumbnail (now for testing, i just do copy to new file with prefix aa_)
3- Display all thumbnail.
I have a problem at step 3. the last thumbnail not display, i have to right click --> choose 'show picture'.
#aspx
| <telerik:RadPane ID="RadPane2" runat="server" Width="300" BorderWidth="3" BorderColor="ActiveBorder"> |
| <input type="hidden" runat="server" id="UploadedFilesJson" /> |
| <center> |
| <object data="data:application/x-silverlight," type="application/x-silverlight-2" width="280" height="120" > |
| <param name="source" value='<%= ResolveUrl("~/Upload.xap") %>'/> |
| <param name="onerror" value="onSilverlightError" /> |
| <param name="background" value="white" /> |
| <param name="minRuntimeVersion" value="2.0.31005.0" /> |
| <param name="windowless" value="true" /> |
| <param name="autoUpgrade" value="true" /> |
| <param name="InitParams" value='<%= InitParameters %>' /> |
| <a href="http://go.microsoft.com/fwlink/?LinkID=124807" style="text-decoration: none;"> |
| <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> |
| </a> |
| </object> |
| </center> |
| <div id="uploaded-files"> |
| </div> |
| </telerik:RadPane> |
#Script in aspx
| <script type="text/javascript"> |
| var $ = $telerik.$; |
| var uploadInProgress; |
| var uploadedFiles = new Array(); |
| function updateHiddenField() { |
| var json = Sys.Serialization.JavaScriptSerializer.serialize(uploadedFiles); |
| $get('UploadedFilesJson').value = json; |
| } |
| // Fired when a file is uploaded |
| function onClientFileUploaded(json) { |
| var uploadedFile = Sys.Serialization.JavaScriptSerializer.deserialize(json); |
| var A = $("<img />") |
| .attr("src", '<%= ResolveUrl(TargetFolder) %>' + uploadedFile.FileName) |
| .load(function(e) { PageMethods.CreateThumbNail(uploadedFile.FileName); }) |
| ; |
| Array.add(uploadedFiles, uploadedFile); |
| } |
| //Called when all files are uploaded |
| function onClientUploadFinished() { |
| updateHiddenField(); |
| var image; var deleteFile; var html=""; |
| for (var i = 0; i < uploadedFiles.length; i++) { |
| image = '<%= ResolveUrl(TargetFolder) %>aa_' + uploadedFiles[i].FileName |
| html += "<img id='img_"+i.toString()+"' width='150px' src='" + image + "' /><br/>"; |
| var aa = document.getElementById("uploaded-files"); |
| } |
| aa.innerHTML = html; |
| } |
| </script> |
| protected string InitParameters |
| { |
| get |
| { |
| List<string> uploadConfig = new List<string>(); |
| uploadConfig.Add("UploadServiceUrl=" + ResolveUrl("~/RadUploadHandler.ashx")); |
| uploadConfig.Add("TargetFolder=" + ResolveUrl(TargetFolder)); |
| uploadConfig.Add("AllowedExtensions=" + "Image Files(*.gif;*.jpg;*.jpeg;*.png)"); |
| uploadConfig.Add("OverwriteExistingFiles=" + true); |
| uploadConfig.Add("IsAutomaticUpload=" + true); |
| uploadConfig.Add("OnClientFileUploaded=" + "onClientFileUploaded"); |
| //Name of the JavaScript function that will be called when all files are uploaded. |
| uploadConfig.Add("OnClientFilesUploadFinished=" + "onClientUploadFinished"); |
| return String.Join(",", uploadConfig.ToArray()); |
| } |
| } |
| private void PopulateUploadedFilesList() |
| { |
| if (!string.IsNullOrEmpty(UploadedFilesJson.Value)) |
| { |
| DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<UploadedFileInfo>)); |
| UploadedFiles = (List<UploadedFileInfo>)serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(UploadedFilesJson.Value))); |
| UploadedFilesJson.Value = string.Empty; |
| } |
| } |
| [WebMethod] |
| public static void DeleteFile(string fileName) |
| { |
| string uploadFolder = HttpContext.Current.Request.MapPath(TargetFolder); |
| File.Delete(Path.Combine(uploadFolder, fileName)); |
| } |
| [WebMethod] |
| public static void CreateThumbNail(string fileName) |
| { |
| string uploadFolder = HttpContext.Current.Request.MapPath(TargetFolder); |
| string pathImg = Path.Combine(uploadFolder, fileName); |
| File.Copy(Path.Combine(uploadFolder, fileName), Path.Combine(uploadFolder, "aa_" +fileName)); |
| // |
| } |
| Hello, i think i've tried just about every option i can find to Collapse the ChildNodes of the Level==0 parent i suspect that is has something to do with the fact that i'm not actually using the " e " in e.Nodes.... to try and do the actual process but i'm trying to use the actual RadTreeView ID collection itself, but the reason i'm doing that is because i want to Collapse all of the Level 0 AAAA node when i then select the Level 0 BBBB node for instance, so if i tried to use the " e " value i would be pointing to the BBBB node which i what i want to expand, but before i expand it, i want to Collapse the AAAA node just for example. thanks for any ideas or suggestins! protected void trvDB2_NodeExpand(object sender, RadTreeNodeEventArgs e) |
| { |
| foreach (RadTreeNode rtn in trvDB2.Nodes) |
| { |
| if (rtn.Level == 0 && !e.Node.Text.Equals(rtn.Text)) |
| { |
| int rntnc = rtn.Nodes.Count; |
| //Nodes ns = rtn.Nodes.Remove(); |
| //for (int index = rtn.Nodes.Count - 1; index >= 0; index--) |
| for (int index = rtn.Nodes.Count - 1; index >= 0; index--) |
| { |
| //string rtnrtntxt0 = rtn.Nodes[index].Text; |
| //if (rtn.Nodes[index].Level==1) |
| //{ |
| // //string rtnrtntxt = rtn.Text; |
| // //string rntnit = rtn.Nodes[index].Text; |
| // rtn.Nodes.Clear(); |
| // //rtn.Nodes[index] |
| // //rtn.Nodes[index]; |
| // //rtn.Nodes |
| //} |
| } |
| //string x = rtn.Text; |
| //IEnumerator ie = rtn.Nodes.GetEnumerator(); |
| //while (ie.MoveNext()) |
| //{ |
| // ((RadTreeNode)(ie.Current)).Nodes.Clear(); |
| //} |
| //foreach (RadTreeNode rtn2 in rtn.Nodes) |
| //{ |
| // //string r = rtn |
| // //rtn2.Nodes.Clear(); |
| // //rtn2.c |
| // //rtn2.Nodes.Clear(); |
| // //rtn.Nodes.Remove(rtn2); |
| //} |
| //rtn.Nodes.Remove(); |
| //rtn.CollapseChildNodes(); |
| //rtn.CollapseParentNodes(); |
| } |
| } |
| for (int index = trvDB2.CheckedNodes.Count - 1; index >= 0; index--) |
| { |
| //trvDB2.CheckedNodes[index].Checked = false; |
| } |
| for (int index = trvDB2.Nodes.Count - 1; index >= 0; index--) |
| { |
| string trvnodetxt = trvDB2.Nodes[index].Text; |
| if (trvDB2.Nodes[index].Level == 0 && !e.Node.Text.Equals(trvnodetxt)) |
| { |
| trvDB2.Nodes[index].CollapseChildNodes(); |
| trvDB2.Nodes[index].Nodes.Clear(); |
| trvDB2.Nodes[index].Remove(); |
| } |
| } |
| //e.Node.CollapseChildNodes(); |
| //e.Node.CollapseParentNodes(); |
| //PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSideCallBack); |
| } |
Telerik.Web.UI.XmlSchedulerProvider
to look after its bookings/appointments. This works well in that the provider handles all the inserts/updates/deletes for me.
I do, however, have a need to send a notification email to the Admin when new appointments get inserted or updated. In this email I want to provide a link to the scheduler, passing the appointment ID in the QueryString so that the appointment in question can be highlighted. This all works great for updates, as the ID is available in the
RadScheduler1_AppointmentUpdate
Method in the e.Appointment.ID property.
The same cannot be said for
RadScheduler1_AppointmentInsert
as the ID is null - I suppose the insert of the xmlProvider has not happened yet.
So my question is, at what point/event can I obtain the ID of the newly created Appointment?
Thanks for any help.
Steele.
Hello,
When I create nodes I have a problem. I have a list:
e.g.:
| class Liste |
| { |
| public string pfad; |
| public Liste(string pfad) |
| { |
| this.pfad = pfad; |
| } |
| } |
| .... |
| if (!IsPostBack) |
| { |
| LadeWerte(); |
| ZeigeTreeView(); |
| } |
| ..... |
| private void LadeWerte() |
| { |
| liste.Add(new Liste("c:\\dateien\\nord\\stad_nord")); |
| liste.Add(new Liste("c:\\dateien\\stad_test")); |
| liste.Add(new Liste("c:\\dateien\\nord\\stad_sued")); |
| } |
| private void ZeigeTreeView() |
| { |
| RadTreeNode rtn = new RadTreeNode("Layouts", "rootfolder"); |
| foreach (Liste list in liste) |
| { |
| Rekursiv(rtn, list.pfad); |
| } |
| RadTreeView1.Nodes.Add(rtn); |
| } |
| private void Rekursiv(RadTreeNode node, string newnode) |
| { |
| if (newnode != "") |
| { |
| RadTreeNode rtn2 = new RadTreeNode(); |
| string substr = ""; |
| if (newnode.LastIndexOf("\\") > 0) |
| substr = newnode.Substring(0, newnode.IndexOf("\\")); |
| else |
| substr = newnode; |
| rtn2.Text = substr; |
| rtn2.Value = "Folder"; |
| string nextnode = ""; |
| if (newnode.IndexOf("\\") > 0) |
| { |
| nextnode = newnode.Substring(newnode.IndexOf("\\") + 1); |
| Rekursiv(rtn2, nextnode); |
| } |
| node.Nodes.Add(rtn2); |
| } |
| } |
Hello,
Our online version of RadEditor is 7.3.2 – RadEditor for ASP .NET
While attempting to migrate to the RadEditor for ASP .NET AJAX we’ve came across these problems:
1. We’re interested in having the editor strip HTML tags (except for BR tags) when the user pastes content into it. Since the stripping is problematic in FF, we’ve written some client code to bring the “paste plain text page” up when the user tries to paste. This is the code we have online:
function OnClientCommandExecuting(editor, commandName, oTool)
{
var browserName=navigator.appName;
if (commandName == "Paste" && browserName!="Microsoft Internet Explorer")
{
editor.Fire("PastePlainText");
return false;
}
}
We’ve changed it to fit the new version thus:
function OnClientCommandExecuting(editor, commandName, oTool)
{
var browserName=navigator.appName;
if (commandName._commandName == 'Paste' && browserName!="Microsoft Internet Explorer")
{
editor.fire("PastePlainText");
return false;
}
}
Which works, but the behavior is different! Instead of bringing up the “paste plain text page”, the editor first puts the clipboard’s content in the content-area of the editor, and only then brings the page up, thereby rendering our efforts useless.
Please advise as to what we can do to solve this problem ?
2. Another problem is, when the user clicks the “paste” button, the “Please use Ctrl+V to Paste” msgbox appears before the “paste plain text page” appears.
How do we suppress this in the new (AJAX) version ?
| <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True" |
| AllowSorting="True" AutoGenerateColumns="False" Width="828px" OnNeedDataSource="RadGrid1_NeedDataSource" |
| OnUpdateCommand="RadGrid1_UpdateCommand" EnableAjaxSkinRendering="true" Skin="Default" |
| OnInsertCommand="RadGrid1_InsertCommand"> |
| <MasterTableView DataKeyNames="ProductID" GridLines="None" Width="100%" CommandItemDisplay="Top"> |
| <Columns> |
| <telerik:GridTemplateColumn HeaderText="Prod.Image" UniqueName="ProductImage"> |
| <ItemTemplate> |
| <asp:Image ID="Image1" ImageUrl='<%# Link.ToProductThumbNail(Eval("Thumbnail").ToString()) %>' |
| runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Prod. Number" UniqueName="ProductNoImage"> |
| <ItemTemplate> |
| <asp:Image ID="Image2" ImageUrl='<%# Link.ToProductNo(Eval("ProductNo").ToString()) %>' |
| runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Name" HeaderText="Prod.Name" UniqueName="ProdName"> |
| </telerik:GridBoundColumn> |
| <telerik:GridHTMLEditorColumn DataField="Description" HeaderText="Prod.Desc" UniqueName="ProdDescription"> |
| </telerik:GridHTMLEditorColumn> |
| <%-- <telerik:GridBoundColumn DataField="Description" HeaderText="Prod.Desc" UniqueName="ProdDescription"> |
| </telerik:GridBoundColumn>--%> |
| <telerik:GridBoundColumn DataField="Price" HeaderText="Price" DataFormatString="{0:£0.00}" |
| UniqueName="ProdPrice"> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn UniqueName="SelectProd"> |
| <ItemTemplate> |
| <asp:HyperLink ID="HyperLink1" runat="server" Text="Select" NavigateUrl='<%# "ProductDetail.aspx?CategoryID=" + |
| Request.QueryString["CategoryID"] + |
| "&ProductIDProductID=" + Eval("ProductID") %>'> |
| </asp:HyperLink> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridCheckBoxColumn Visible="false" DataField="PromoFront" HeaderText="Cat.Promo" |
| UniqueName="PromoFront"> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridCheckBoxColumn Visible="false" DataField="PromoDept" HeaderText="Dept.Promo" |
| UniqueName="PromoDept"> |
| </telerik:GridCheckBoxColumn> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| </Columns> |
| <EditFormSettings ColumnNumber="2" CaptionFormatString="Edit details for:{0}" CaptionDataField="Name"> |
| <FormTableItemStyle Wrap="False"></FormTableItemStyle> |
| <FormCaptionStyle></FormCaptionStyle> |
| <FormMainTableStyle CellSpacing="0" CellPadding="3" Width="100%" /> |
| <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" Height="110px" |
| Width="100%" /> |
| <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
| <FormStyle Width="100%" BackColor="#EEF2EA"></FormStyle> |
| <EditColumn UpdateText="Update" UniqueName="EditCommandColumn1" CancelText="Cancel"> |
| </EditColumn> |
| <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> |
| </EditFormSettings> |
| <ExpandCollapseColumn Visible="False"> |
| <HeaderStyle Width="19px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <RowIndicatorColumn Visible="False"> |
| <HeaderStyle Width="20px" /> |
| </RowIndicatorColumn> |
| </MasterTableView> |
| </telerik:RadGrid> |
| protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) |
| { |
| //Get the GridEditableItem of the RadGrid |
| GridEditableItem editedItem = e.Item as GridEditableItem; |
| //Get the primary key value using the DataKeyValue. |
| string id = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["ProductID"].ToString(); |
| //Access the textbox from the edit form template and store the values in string variables. |
| //string productno = (editedItem["ProductNo"].Controls[0] as TextBox).Text; |
| string name = (editedItem["ProdName"].Controls[0] as TextBox).Text; |
| string description = (editedItem["ProdDescription"].Controls[0] as GridHTMLEditorColumnEditor).Text; |
| string price = (editedItem["ProdPrice"].Controls[0] as TextBox).Text; |
| //string thumbnail = (editedItem["ProdThumbnail"].Controls[0] as TextBox).Text; |
| //string image = (editedItem["ProdImage"].Controls[0] as TextBox).Text; |
| string promoDept = (editedItem["PromoDept"].Controls[0] as CheckBox).Checked.ToString(); |
| string promoFront = (editedItem["PromoFront"].Controls[0] as CheckBox).Checked.ToString(); |
| try |
| { |
| CatalogAccess.UpdateProduct(id,name,description.ToString(),price,promoDept, promoFront); |
| } |
| catch (Exception ex) |
| { |
| RadGrid1.Controls.Add(new LiteralControl("Unable to update Category. Reason: " + ex.Message)); |
| e.Canceled = true; |
| } |
| } |
| Object reference not set to an instance of an object. |
| Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
| Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. |
| Source Error: |
| Line 51: //string productno = (editedItem["ProductNo"].Controls[0] as TextBox).Text; |
| Line 52: string name = (editedItem["ProdName"].Controls[0] as TextBox).Text; |
| Line 53: string description = (editedItem["ProdDescription"].Controls[0] as GridHTMLEditorColumnEditor).Text; |
| Line 54: string price = (editedItem["ProdPrice"].Controls[0] as TextBox).Text; |
| Line 55: //string thumbnail = (editedItem["ProdThumbnail"].Controls[0] as TextBox).Text; |
var
ajaxManager = $find("<%= this.Page.AjaxManager.ClientID %>");
ajaxManager.ajaxRequestWithTarget('<%= Button_EditEntry.UniqueID %>', oWnd.argument);
The trouble is, this works fine within a page, but within a UserControl I seem to be faced with a dilema:
To retrieve the argument passed in the Ajax Request, I have to implement a RaisePostBackEvent method in my code-behind. For a page, this is a simple matter of overriding the page's implementation of this. For a UserControl, I have to implement IPostBackEventHandler. According to the documentation, to ensure that my RaisePostBackEvent function gets called, I have to call ajaxRequestWithTarget using the UniqueID of the UserControl itself instead of the button, but if I do that, all the controls within the UserControl get updated during the Ajax Request instead of just those controls that Button_EditEntry should affect.
Within a UserControl, how can I initiate an Ajax call on the client side, retrieve the argument on the server side, and limit the controls that are updated to one or two instead of the entire UserControl?
Jeff