Manual upload is not working
i want create something like filemail.com
file should be uploaded and that link has to be send to sender and receiver.
but both uploading of file and mail has to happen in one single button. im not much familiar with programming and new to telerik controls. examples in telerik is so not so clear.
for this purpose i used RADASYNCUPLOAD with manual upload and RADBUTTON.
Everything was fine but no file uploaded.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 6px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<script type="text/javascript">
//Put your JavaScript code here.
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<table class="auto-style1">
<tr>
<td>To (email):</td>
<td> <telerik:RadTextBox ID="RadTextBoxTo" runat="server" Height="16px" OnTextChanged="RadTextBoxTo_TextChanged" Width="521px"></telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>From (email): </td>
<td> <telerik:RadTextBox ID="RadTextBoxFrom" runat="server" Height="16px" Width="525px"></telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>Subject:</td>
<td>
<telerik:RadTextBox ID="RadTextBoxSubject" Runat="server" Height="18px" Width="528px">
</telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>Message </td>
<td>
<telerik:RadTextBox ID="RadTextBoxBody" Runat="server" Height="112px" Width="530px">
</telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td> </td>
<td>
<div style="height: 24px">
<script type="text/javascript" id="telerikClientEvents1">
//<![CDATA[
function RadButtonSend_Clicked(sender, args) {
var upload = $find('<%=RadAsyncUpload1.ClientID%>');
upload.startUpload();
}
//]]>
</script>
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" DropZones="Dropzone1" ManualUpload="True" MultipleFileSelection="Automatic" Skin="Telerik" >
</telerik:RadAsyncUpload>
</div>
<br />
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>
</td>
<td>
<telerik:RadButton ID="RadButtonSend" runat="server" Text="Send" OnClick="RadButton1_Click" OnClientClicked="RadButtonSend_Clicked">
</telerik:RadButton>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="LabelMessage" runat="server"></asp:Label>
</td>
<td class="auto-style2"> </td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</form>
</body>
</html>
i want create something like filemail.com
file should be uploaded and that link has to be send to sender and receiver.
but both uploading of file and mail has to happen in one single button. im not much familiar with programming and new to telerik controls. examples in telerik is so not so clear.
for this purpose i used RADASYNCUPLOAD with manual upload and RADBUTTON.
Everything was fine but no file uploaded.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 6px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<script type="text/javascript">
//Put your JavaScript code here.
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<table class="auto-style1">
<tr>
<td>To (email):</td>
<td> <telerik:RadTextBox ID="RadTextBoxTo" runat="server" Height="16px" OnTextChanged="RadTextBoxTo_TextChanged" Width="521px"></telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>From (email): </td>
<td> <telerik:RadTextBox ID="RadTextBoxFrom" runat="server" Height="16px" Width="525px"></telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>Subject:</td>
<td>
<telerik:RadTextBox ID="RadTextBoxSubject" Runat="server" Height="18px" Width="528px">
</telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>Message </td>
<td>
<telerik:RadTextBox ID="RadTextBoxBody" Runat="server" Height="112px" Width="530px">
</telerik:RadTextBox>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td> </td>
<td>
<div style="height: 24px">
<script type="text/javascript" id="telerikClientEvents1">
//<![CDATA[
function RadButtonSend_Clicked(sender, args) {
var upload = $find('<%=RadAsyncUpload1.ClientID%>');
upload.startUpload();
}
//]]>
</script>
<telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" DropZones="Dropzone1" ManualUpload="True" MultipleFileSelection="Automatic" Skin="Telerik" >
</telerik:RadAsyncUpload>
</div>
<br />
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>
</td>
<td>
<telerik:RadButton ID="RadButtonSend" runat="server" Text="Send" OnClick="RadButton1_Click" OnClientClicked="RadButtonSend_Clicked">
</telerik:RadButton>
</td>
<td class="auto-style2"> </td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="LabelMessage" runat="server"></asp:Label>
</td>
<td class="auto-style2"> </td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
</form>
</body>
</html>
13 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 21 Feb 2014, 04:13 AM
Hi,
Please have a look into the following code snippet to upload a file manullay and please take a look into this online demo.
ASPX:
JavaScript:
Thanks,
Shinu.
Please have a look into the following code snippet to upload a file manullay and please take a look into this online demo.
ASPX:
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"RadAsyncUpload1"
ManualUpload
=
"true"
MultipleFileSelection
=
"Automatic"
/>
<
input
type
=
"button"
onclick
=
"startManualUpload()"
value
=
"start upload"
/>
JavaScript:
<script type=
"text/javascript"
>
function
startManualUpload() {
var
upload = $find(
'<%=RadAsyncUpload1.ClientID%>'
);
upload.startUpload();
}
</script>
Thanks,
Shinu.
0
axxo
Top achievements
Rank 1
answered on 21 Feb 2014, 06:28 AM
thank u shinu. i know this is possible with code that you gave me. how we can do the same with RADButton. is it possible or not? i dont want to increase number of buttons. one button should be used to upload the file and send the link by email to both sender and receiver.
0
Shinu
Top achievements
Rank 2
answered on 21 Feb 2014, 08:16 AM
Hi,
Please try the following code snippet which works fine at my end.
ASPX:
Thanks,
Shinu.
Please try the following code snippet which works fine at my end.
ASPX:
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"RadAsyncUpload1"
ManualUpload
=
"true"
MultipleFileSelection
=
"Automatic"
/>
<
telerik:RadButton
ID
=
"RadButtonSend"
runat
=
"server"
Text
=
"Send"
AutoPostBack
=
"false"
OnClientClicked
=
"startManualUpload"
>
</
telerik:RadButton
>
Thanks,
Shinu.
0
axxo
Top achievements
Rank 1
answered on 21 Feb 2014, 09:47 AM
im getting strange script errors:
Im getting the script error why?
i tried also the example given in the telerik site. it also given the same error
Unhandled exception at line 4168, column 2 in http://localhost:21350/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken=31bf3856ad364e35:en-US:c9cbdec3-c810-4e87-846c-fb25a7c08002:ea597d4b:b25378d2;Telerik.Web.UI:en-US:9711a23a-6cf5-4e6c-87f5-29e6585b3026:16e4e7cd:f7645509:22a6274a:ed16cbdc:b7778d6c:24ee1bba:52af31a4:7165f74
Im getting the script error why?
i tried also the example given in the telerik site. it also given the same error
function k(x,D,A,B){var y=null;
try{y=x.contentDocument||x.contentWindow.document;
}catch(v){m(A);
B.trigger("FileUploadFail",D,"");
return;
}if(y){if(a(D).parents().length==0){return;
}var C="";
try{var z=y.body.innerHTML.trim();
if(z!=""&&z!=undefined){C=a.parseJSON(y.body.innerHTML);
}else{C=null;
}}catch(v){m(A);
h(D);
if(t==0){B._marshalHoldContext();
}B.trigger("FileUploadFail",D,y.body.innerHTML);
return;
}if(C){if(C.invalidFileSize||C.invalidFileExtension){m(A);
h(D);
var u=a(".ruUploadProgress",D);
a(".ruFileProgressWrap",u).remove();
var w=u.html();
if(t==0){B._marshalHoldContext();
}B.trigger("FileValidationFail",w,D);
return;
}m(A);
h(D);
B.trigger("FileUploaded",D,C);
if(t==0){B._marshalHoldContext();
B.trigger("FilesUploaded",D);
}}}}
0
axxo
Top achievements
Rank 1
answered on 21 Feb 2014, 09:49 AM
hmm i think its size restriction.
0
axxo
Top achievements
Rank 1
answered on 21 Feb 2014, 10:10 AM
i tried shinu. its still give me error. when i tried small files it didnt give any error. but no file uploaded to tempfolder. why is that? i tried different ways.
0
Shinu
Top achievements
Rank 2
answered on 24 Feb 2014, 05:17 AM
Hi,
Unfortunately I couldn't replicate the issue at my end. Please have a look into the full code which works fine at my end and I am using telerik version 2013, 3, 1015, 45.
ASPX:
JavaScript:
Thanks,
Shinu.
Unfortunately I couldn't replicate the issue at my end. Please have a look into the full code which works fine at my end and I am using telerik version 2013, 3, 1015, 45.
ASPX:
<
table
class
=
"auto-style1"
>
<
tr
>
<
td
>
To (email):
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxTo"
runat
=
"server"
Height
=
"16px"
Width
=
"521px"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
From (email):
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxFrom"
runat
=
"server"
Height
=
"16px"
Width
=
"525px"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Subject:
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxSubject"
runat
=
"server"
Height
=
"18px"
Width
=
"528px"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
Message
</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxBody"
runat
=
"server"
Height
=
"112px"
Width
=
"530px"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
div
style
=
"height: 24px"
>
<
telerik:RadAsyncUpload
runat
=
"server"
ID
=
"RadAsyncUpload1"
ManualUpload
=
"true"
MultipleFileSelection
=
"Automatic"
/>
</
div
>
<
br
/>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
telerik:RadButton
ID
=
"RadButtonSend"
runat
=
"server"
Text
=
"Send"
AutoPostBack
=
"false"
OnClientClicked
=
"startManualUpload"
Style
=
"margin-top: 25px"
>
</
telerik:RadButton
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
asp:Label
ID
=
"LabelMessage"
runat
=
"server"
></
asp:Label
>
</
td
>
<
td
class
=
"auto-style2"
>
</
td
>
</
tr
>
</
table
>
JavaScript:
<script type=
"text/javascript"
>
function
startManualUpload() {
var
upload = $find(
'<%=RadAsyncUpload1.ClientID%>'
);
upload.startUpload();
}
</script>
Thanks,
Shinu.
0
axxo
Top achievements
Rank 1
answered on 25 Feb 2014, 08:40 PM
thank u shinu.
i solved the issue. but my problem was with IE 11. now let me tell u another thing.
i want to just upload with just one button click.
i used radasyncupload as manual upload. then i disable the radbutton post back. then onclientfilesuploaded i used the script to dopostback script.
initially when i start my project i thougt to use it by file system method. later i thought to upload file to sql server filestream directly using entity framework. how to do this?
im not much familiar vth http handler as u mentioned in one of the forum
i solved the issue. but my problem was with IE 11. now let me tell u another thing.
i want to just upload with just one button click.
i used radasyncupload as manual upload. then i disable the radbutton post back. then onclientfilesuploaded i used the script to dopostback script.
initially when i start my project i thougt to use it by file system method. later i thought to upload file to sql server filestream directly using entity framework. how to do this?
im not much familiar vth http handler as u mentioned in one of the forum
0
Hello,
You can refer to this on-line demo where similar functionality is implemented and the file is uploaded to a DataSource from the code behind in the "RadGrid1_InsertCommand" method.
Hope this information will be helpful.
Regards,
Plamen
Telerik
You can refer to this on-line demo where similar functionality is implemented and the file is uploaded to a DataSource from the code behind in the "RadGrid1_InsertCommand" method.
Hope this information will be helpful.
Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
axxo
Top achievements
Rank 1
answered on 27 Feb 2014, 01:53 PM
i created almost the same. there is no httphandler used. but the problem is that it waits for some times to do the sql server upload process. I want to avoid that.
progress bar closes immediately after uploading to temp folder i think. i want progress bar to continue until the sql upload process completes.
progress bar closes immediately after uploading to temp folder i think. i want progress bar to continue until the sql upload process completes.
0
Hi,
You could achieve similar behavior by implementing the process as for example in the code below. Measuring the exact process of the uploading file is not supported at the moment.
Hope this information will be helpful.
Regards,
Plamen
Telerik
You could achieve similar behavior by implementing the process as for example in the code below. Measuring the exact process of the uploading file is not supported at the moment.
Hope this information will be helpful.
Regards,
Plamen
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
axxo
Top achievements
Rank 1
answered on 04 Mar 2014, 12:32 PM
thnk u for the reply and code.
even though the code may work for progress bar. since im not using httphandler the thing is that files will first upload to temporary folder and then upload to database. this really makes double time. because database may b in anohter machine.
so if u upload 100mb file it will first upload to temp folder dna against almost thesame time to upload to database.
so i now badly need to think about httphandler method.
so if i upload directly to database is it possible for me to get the filename and fileextension and content type.
i alsso found im not getting contentype correctly. especially dwg, xlsx files and all. its downloading without any extension.why?
default.aspx
even though the code may work for progress bar. since im not using httphandler the thing is that files will first upload to temporary folder and then upload to database. this really makes double time. because database may b in anohter machine.
so if u upload 100mb file it will first upload to temp folder dna against almost thesame time to upload to database.
so i now badly need to think about httphandler method.
so if i upload directly to database is it possible for me to get the filename and fileextension and content type.
i alsso found im not getting contentype correctly. especially dwg, xlsx files and all. its downloading without any extension.why?
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using System.Data;
using System.Linq;
//using System.Data.Entity;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using System.IO;
using System.IO.Compression;
using System.Net;
using System.Net.Mail;
using System.Web.Routing;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadTextBoxTo_TextChanged(object sender, EventArgs e)
{
}
protected void RadButton1_Click(object sender, EventArgs e)
{
HttpFileCollection filesColl = Request.Files;
idroesseEntities idsentities = new idroesseEntities();
//RadAsyncUpload1.TargetFolder = "~/App_Data/Uploadedfiles";
//subPath ="ImagesPath";
//idsentities.Files1.
SessionTB sessTB = new SessionTB();
MailTB mailtb = new MailTB();
string Sessionstr = System.IO.Path.GetRandomFileName();
Sessionstr = Sessionstr.Replace(".", "");
int Sessionverification = idsentities.SessionTBs.ToList().Where(x => x.Session == Sessionstr).Count();
if (Sessionverification == 0)
{
sessTB.Session = Sessionstr;
idsentities.SessionTBs.Add(sessTB);
idsentities.SaveChanges();
sessTB = idsentities.SessionTBs.ToList().Where(x => x.Session == Sessionstr).First();
}
//string subPath = "~/App_Data/Uploadedfiles/" + subpathwithperiod;
//bool isExists = System.IO.Directory.Exists(Server.MapPath(subPath));
long filesize = 0;
int numberOfFiles = 0;
// if (!isExists)
// {
//System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
DateTime dt = DateTime.Now;
foreach (UploadedFile uploadedfile in RadAsyncUpload1.UploadedFiles)
{
// UploadedFile uploadedfile = RadAsyncUpload1.UploadedFiles[0];
string filename = Path.GetFileName(uploadedfile.FileName);
string contenttype = Path.GetFileName(uploadedfile.ContentType);
string ext = Path.GetExtension(uploadedfile.FileName);
Files1 files = new Files1();
Stream stream = uploadedfile.InputStream;
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
files.FileContents = buffer;
//files.CreationDate = DateTime.Now;
files.CreationDate = dt;
files.FileName = Path.GetFileName(uploadedfile.FileName); ;
//files.Extension= da valorizzare
files.Extension = Path.GetExtension(uploadedfile.FileName);
files.FileSize = uploadedfile.ContentLength;
files.FileID = Guid.NewGuid();
files.ContentType = Path.GetFileName(uploadedfile.ContentType);
files.FileLifeTime = Convert.ToInt32(RadTextBoxFileLife.Text);
files.SessionId = sessTB.SessionID;
if(chkBoxNotify.Checked==true)
files.NotifyDownload=true;
else
files.NotifyDownload = false;
if (chkBoxNotify.Checked == true)
files.ProtectPagePassword = true;
else
files.ProtectPagePassword = false;
idsentities.Files1.Add(files);
idsentities.SaveChanges();
//string saveas=subPath+"/"+f.GetName();
////f.SaveAs(Server.MapPath(subPath) + "/" + f.GetName(), true);
filesize = filesize + uploadedfile.ContentLength;
//filesize1=RadAsyncUpload1.InputSize;
numberOfFiles++;
//}
//ZipFile.CreateFromDirectory(Server.MapPath(subPath), Path.Combine(Server.MapPath(subPath),"user1.zip"));
//string fromMail = "support@idroesse.com; " + RadTextBoxFrom.Text;
RadTextBoxFrom.Text= "itadmin@idroesse.com";
RadTextBoxTo.Text = "itadmin@idroesse.com";
RadTextBoxSubject.Text="test 11" ;
RadTextBoxBody.Text = "just a test";
mailtb.MailFrom = RadTextBoxFrom.Text;
mailtb.MailTo = RadTextBoxTo.Text;
mailtb.MailSubject = RadTextBoxSubject.Text;
mailtb.MailBody = RadTextBoxBody.Text;
mailtb.SessionID = sessTB.SessionID;
idsentities.MailTBs.Add(mailtb);
idsentities.SaveChanges();
Session["MailTo"]=RadTextBoxTo.Text;
Session["MailFrom"]=RadTextBoxFrom.Text;
Session["MailBody"]=RadTextBoxBody.Text ;
Session["numberOfFiles"] = numberOfFiles;
Session["SessionID"] = sessTB.SessionID;
//Response.Write("<
br
/> " + HttpContext.Current.Request.Url.Host);
//Response.Write("<
br
/> " + HttpContext.Current.Request.Url.Authority);
//Response.Write("<
br
/> " + HttpContext.Current.Request.Url.AbsolutePath);
//Response.Write("<
br
/> " + HttpContext.Current.Request.ApplicationPath);
//Response.Write("<
br
/> " + HttpContext.Current.Request.Url.AbsoluteUri);
//Response.Write("<
br
/> " + HttpContext.Current.Request.Url.PathAndQuery);
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
Server.Execute("Default3.aspx", htw);
//string url1 = "http://" + HttpContext.Current.Request.Url.Authority + "/mail/" + sessTB.SessionID;
//Server.Execute(url1, htw);
//CookieContainer cookies = new CookieContainer();
//WebRequest request = WebRequest.Create("http://localhost:21350/Default3.aspx");
//HttpWebRequest request =(HttpWebRequest) WebRequest.Create("http://localhost:21350/Default3.aspx");
//request.AllowAutoRedirect = true;
//request.CookieContainer = cookies;
//WebResponse response = request.GetResponse();
// HttpWebResponse response = (HttpWebResponse)request.GetResponse();
//Stream dataStream = response.GetResponseStream();
//StreamReader reader = new StreamReader(dataStream);
//StringReader reader = new StringReader(response.GetResponseStream());
//string html = reader.ReadToEnd();
//
//
//MailMessage mail = new MailMessage(RadTextBoxFrom.Text, RadTextBoxTo.Text, RadTextBoxSubject.Text, reader.ReadToEnd());
MailMessage mail = new MailMessage(RadTextBoxFrom.Text, RadTextBoxTo.Text, RadTextBoxSubject.Text, sw.ToString());
mail.IsBodyHtml=true;
SmtpClient SMTPServer = new SmtpClient("mail.idroesseuae.com", 25);
SMTPServer.Credentials = new System.Net.NetworkCredential("jahesh@idroesse.local", "p@ssword");
//mail.Bcc.Add(new MailAddress("itadmin@idroesse.com"));
////SMTPServer.UseDefaultCredentials = true;
////SMTPServer.DeliveryMethod = SmtpDeliveryMethod.Network;
////SMTPServer.EnableSsl = true;
SMTPServer.Timeout = 30000;
//reader.Close();
//dataStream.Close();
//response.Close();
try
{
SMTPServer.Send(mail);
LabelMessage.Text = "Mail Send Successfully filesize: " + filesize.ToString();
}
catch (Exception ex)
{
LabelMessage.Text = ex.ToString();
}
}
string url="/t/"+sessTB.SessionID;
Response.Redirect(url);
}
protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
string subpathwithperiod = System.IO.Path.GetRandomFileName();
subpathwithperiod = subpathwithperiod.Replace(".", "");
string subPath = "~/App_Data/Uploadedfiles/" + subpathwithperiod;
bool isExists = System.IO.Directory.Exists(Server.MapPath(subPath));
if (!isExists)
{
foreach ( UploadedFile f in RadAsyncUpload1.UploadedFiles)
{
System.IO.Directory.CreateDirectory(Server.MapPath(subPath));
//string saveas=subPath+"/"+f.GetName();
f.SaveAs(Server.MapPath(subPath) + "/" + f.GetName(), true);
}
}
}
}
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
telerik:RadStyleSheetManager
id
=
"RadStyleSheetManager1"
runat
=
"server"
/>
<
style
type
=
"text/css"
>
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 6px;
}
#spinner {
width: 63px;
}
.auto-style8 {
width: 340px;
}
.auto-style9 {
width: 190px;
}
</
style
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function startManualUpload() {
var upload = $find('<%=RadAsyncUpload1.ClientID%>');
upload.startUpload();
//i = 0;
//while(i==0)
//{
// if (upload.getUpload().length > 0) {
// __doPostBack('RadButtonSend', '');
// i++;
// }
//}
}
</
script
>
<
script
type
=
"text/javascript"
id
=
"telerikClientEvents1"
>
//
<![CDATA[
function RadButtonSend_Clicked(sender, args) {
var wnd = $find("<%=RadWindowModalPopup.ClientID %>");
wnd.close();
var upload = $find('<%=RadAsyncUpload1.ClientID%>');
upload.startUpload();
//__doPostBack('RadButtonSend', '');
}
//]]>
</
script
>
<
script
type
=
"text/javascript"
id
=
"telerikClientEvents2"
>
//
<![CDATA[
function RadButtonSend_Clicking(sender, args) {
//Add JavaScript handler code here
var upload = $find('<%=RadAsyncUpload1.ClientID%>');
upload.startUpload();
//__doPostBack('RadButton2', '');
}
//]]>
</
script
>
<
script
type
=
"text/javascript"
id
=
"telerikClientEvents3"
>
//
<![CDATA[
function RadAsyncUpload1_FilesUploaded(sender, args) {
__doPostBack('RadButton1', '');
}
//]]>
</
script
>
<
script
type
=
"text/javascript"
>
function modalPopUp() {
var wnd = $find("<%=RadWindowModalPopup.ClientID %>");
wnd.show();
}
</
script
>
<
script
type
=
"text/javascript"
id
=
"telerikClientEvents5"
>
//
<![CDATA[
function RadButtonCancel_Clicked(sender, args) {
//Add JavaScript handler code here
var wnd = $find("<%=RadWindowModalPopup.ClientID %>");
wnd.close();
}
//]]>
</
script
>
</
telerik:RadCodeBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
script
type
=
"text/javascript"
>
//Put your JavaScript code here.
</
script
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
</
telerik:RadAjaxManager
>
<
table
class
=
"auto-style1"
>
<
tr
>
<
td
>To (email):</
td
>
<
td
> <
telerik:RadTextBox
ID
=
"RadTextBoxTo"
runat
=
"server"
Height
=
"23px"
OnTextChanged
=
"RadTextBoxTo_TextChanged"
Width
=
"521px"
></
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
>From (email): </
td
>
<
td
> <
telerik:RadTextBox
ID
=
"RadTextBoxFrom"
runat
=
"server"
Height
=
"23px"
Width
=
"525px"
></
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
>Subject:</
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxSubject"
Runat
=
"server"
Height
=
"18px"
Width
=
"528px"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
>Message </
td
>
<
td
>
<
telerik:RadTextBox
ID
=
"RadTextBoxBody"
Runat
=
"server"
Height
=
"112px"
Width
=
"530px"
Resize
=
"None"
TextMode
=
"MultiLine"
>
</
telerik:RadTextBox
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
> </
td
>
<
td
>
<
div
style
=
"height: 24px"
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
ManualUpload
=
"True"
MultipleFileSelection
=
"Automatic"
Skin
=
"Telerik"
OnClientFilesUploaded
=
"RadAsyncUpload1_FilesUploaded"
EnableInlineProgress
=
"False"
>
</
telerik:RadAsyncUpload
>
<
telerik:RadProgressManager
runat
=
"server"
ID
=
"RadProgressManager1"
/>
<
telerik:RadProgressArea
runat
=
"server"
ID
=
"RadProgressArea1"
Skin
=
"Hay"
/>
<
input
type
=
"button"
onclick
=
"startManualUpload()"
value
=
"start upload"
/>
<%--<
input
type
=
"button"
onclick
=
"modalPopUp()"
value
=
"Send"
/>--%>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
AutoPostBack
=
"False"
OnClick
=
"RadButton1_Click"
Text
=
"Send"
OnClientClicked
=
"modalPopUp"
>
</
telerik:RadButton
>
</
div
>
<
div
>
<
telerik:RadAjaxLoadingPanel
runat
=
"server"
ID
=
"ralpConfiguration"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadAjaxPanel
runat
=
"server"
ID
=
"rapConfiguration"
LoadingPanelID
=
"ralpConfiguration"
>
<
telerik:RadWindow
ID
=
"RadWindowModalPopup"
runat
=
"server"
Modal
=
"True"
Height
=
"265px"
Skin
=
"Default"
Width
=
"560px"
VisibleTitlebar
=
"False"
>
<
ContentTemplate
>
<
h2
>Transfer Options</
h2
>
<
table
>
<
tr
>
<
td
class
=
"auto-style8"
>
</
td
>
<
td
class
=
"auto-style9"
> </
td
>
</
tr
>
<
tr
>
<
td
class
=
"auto-style8"
>Files will be available:</
td
>
<
td
class
=
"auto-style9"
><
span
class
=
"ui-spinner ui-widget ui-widget-content ui-corner-all"
>
<
telerik:RadTextBox
ID
=
"RadTextBoxFileLife"
Runat
=
"server"
Height
=
"16px"
Width
=
"61px"
Skin
=
"Default"
>
</
telerik:RadTextBox
>
</
span
><
span
class
=
"popupSpanDays"
>Days</
span
></
td
>
</
tr
>
<
tr
>
<
td
class
=
"auto-style8"
>Notify me when files are downloaded:</
td
>
<
td
class
=
"auto-style9"
>
<
asp:CheckBox
ID
=
"chkBoxNotify"
runat
=
"server"
Checked
=
"True"
/>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"auto-style8"
>Protect download page with password:</
td
>
<
td
class
=
"auto-style9"
>
<
asp:CheckBox
ID
=
"chkboxPassword"
runat
=
"server"
/>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"auto-style8"
>
</
td
>
<
td
class
=
"auto-style9"
>
<
telerik:RadButton
ID
=
"RadButtonCancel"
runat
=
"server"
AutoPostBack
=
"False"
OnClientClicked
=
"RadButtonCancel_Clicked"
Text
=
"Cancel"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButtonSend"
runat
=
"server"
AutoPostBack
=
"False"
OnClientClicked
=
"RadButtonSend_Clicked"
Text
=
"Send"
>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
</
ContentTemplate
>
</
telerik:RadWindow
>
</
telerik:RadAjaxPanel
>
</
div
>
<
br
/>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
AutoPostBack
=
"False"
OnClick
=
"RadButton1_Click"
Text
=
"Send"
OnClientClicked
=
"RadButtonSend_Clicking"
>
</
telerik:RadButton
>
</
td
>
<
td
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
<
td
>
<
asp:Label
ID
=
"LabelMessage"
runat
=
"server"
></
asp:Label
>
</
td
>
<
td
class
=
"auto-style2"
> </
td
>
</
tr
>
</
table
>
<
br
/>
<
asp:HyperLink
ID
=
"HyperLink1"
runat
=
"server"
NavigateUrl
=
"t/2"
>HyperLink</
asp:HyperLink
>
<
br
/>
2<
br
/>
<
br
/>
<
br
/>
</
form
>
</
body
>
</
html
>
0
Hi axxo,
You can refer to this on-line demo where is implemented one possible way to how Custom Http Handler can be used.
I have also inspected your code and noticed that you are looping through the uploaded files in the Button click event- please have in mind that in such scenarios we recommend using the fileUplaoded event which is thrown for every file and add your custom logic there instead of looping the files again after that.
Hope this will be helpful.
Regards,
Plamen
Telerik
You can refer to this on-line demo where is implemented one possible way to how Custom Http Handler can be used.
I have also inspected your code and noticed that you are looping through the uploaded files in the Button click event- please have in mind that in such scenarios we recommend using the fileUplaoded event which is thrown for every file and add your custom logic there instead of looping the files again after that.
Hope this will be helpful.
Regards,
Plamen
Telerik
DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!