Hi,
I'm having the weirdest problem with the RadUpload control.
I was trying to integrate the control in a fairly complicated aspx page and got the following error from Visual Studio (9.0.etc.) when running the page in debug mode:
"Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element"
I tried to read up on this problem on the internet but couldn't make much sense of what is written on the subject.
So I decided to make a test page just for this control, following the instructions in the "RadControls for ASPNET AJAX Q1 2008 Documentation" (or at least for the larger part), to see how I could get it working.
And guess what? It worked!
So I started experimenting with renaming the uploaded file and stuff and it still worked. Up to a certain point...
The thing is I don't see what it was that caused a problem. To me it seems as if from one moment to the other it just stopped working.
Although the problem was not the same error. All of the sudden "rulMediaUpload.UploadedFiles[0]" became null all the time.
I grew tired of it yesterday so I dropped it for the day. This morning I decided to comment all lines but those with I think it was I started with when making the test page the first time, when it still worked. And now I'm stuck again with the "Value must not be null for Controls and Behaviors" error from Visual Studio...
I really can't see what the difference is between the code as it is this morning and yesterday morning (ignoring the commented lines) except that it did work yesterday!
This is the code in the aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadUploadTest.aspx.cs" Inherits="CMS.Views.Tests.RadUploadTest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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>
<script type="text/javascript">
function pageLoad() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<!--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>-->
<telerik:RadUpload runat="server"
AllowedFileExtensions=".jpg,.jpeg,.gif,.png,.bmp,.aac,.mp3,.wav,.wma,.asf,.avi,.mov,.mp4,.mpg,.qt,.swf,.wmv"
ControlObjectsVisibility="None" MaxFileInputsCount="1" MaxFileSize="5000000"
TargetFolder="~\Upload\Media" ID="rulMediaUpload" />
<!--<telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
<telerik:RadProgressArea ID="RadProgressArea1" Runat="server" DisplayCancelButton="True" ProgressIndicators="TotalProgressPercent">
</telerik:RadProgressArea>-->
<asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" />
<!--</ContentTemplate>
</asp:UpdatePanel>-->
</div>
</form>
</body>
</html>
And this is the code in the corresponding aspx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace CMS.Views.Tests
{
public partial class RadUploadTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//string defaultTempFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"xxx.jpg");
//DateTime d = DateTime.Now;
//string s = "" + d.Year + d.Month.ToString().PadLeft(2, '0') + d.Day.ToString().PadLeft(2, '0') + d.Hour.ToString().PadLeft(2, '0') + d.Minute.ToString().PadLeft(2, '0');
//string FinalFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"final-"+s+".jpg");
//rulMediaUpload.UploadedFiles[0].SaveAs(defaultTempFileName);
//FileInfo uploadedFile = new FileInfo(defaultTempFileName);
//uploadedFile.MoveTo(FinalFileName);
}
}
}
In both files the commented lines didn't cause any problems when not commented until... they did!
Please help me out here.
I'm having the weirdest problem with the RadUpload control.
I was trying to integrate the control in a fairly complicated aspx page and got the following error from Visual Studio (9.0.etc.) when running the page in debug mode:
"Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
Parameter name: element"
I tried to read up on this problem on the internet but couldn't make much sense of what is written on the subject.
So I decided to make a test page just for this control, following the instructions in the "RadControls for ASPNET AJAX Q1 2008 Documentation" (or at least for the larger part), to see how I could get it working.
And guess what? It worked!
So I started experimenting with renaming the uploaded file and stuff and it still worked. Up to a certain point...
The thing is I don't see what it was that caused a problem. To me it seems as if from one moment to the other it just stopped working.
Although the problem was not the same error. All of the sudden "rulMediaUpload.UploadedFiles[0]" became null all the time.
I grew tired of it yesterday so I dropped it for the day. This morning I decided to comment all lines but those with I think it was I started with when making the test page the first time, when it still worked. And now I'm stuck again with the "Value must not be null for Controls and Behaviors" error from Visual Studio...
I really can't see what the difference is between the code as it is this morning and yesterday morning (ignoring the commented lines) except that it did work yesterday!
This is the code in the aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadUploadTest.aspx.cs" Inherits="CMS.Views.Tests.RadUploadTest" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!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>
<script type="text/javascript">
function pageLoad() {
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<!--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>-->
<telerik:RadUpload runat="server"
AllowedFileExtensions=".jpg,.jpeg,.gif,.png,.bmp,.aac,.mp3,.wav,.wma,.asf,.avi,.mov,.mp4,.mpg,.qt,.swf,.wmv"
ControlObjectsVisibility="None" MaxFileInputsCount="1" MaxFileSize="5000000"
TargetFolder="~\Upload\Media" ID="rulMediaUpload" />
<!--<telerik:RadProgressManager ID="RadProgressManager1" Runat="server" />
<telerik:RadProgressArea ID="RadProgressArea1" Runat="server" DisplayCancelButton="True" ProgressIndicators="TotalProgressPercent">
</telerik:RadProgressArea>-->
<asp:Button ID="Button1" runat="server" Text="submit" onclick="Button1_Click" />
<!--</ContentTemplate>
</asp:UpdatePanel>-->
</div>
</form>
</body>
</html>
And this is the code in the corresponding aspx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace CMS.Views.Tests
{
public partial class RadUploadTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//string defaultTempFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"xxx.jpg");
//DateTime d = DateTime.Now;
//string s = "" + d.Year + d.Month.ToString().PadLeft(2, '0') + d.Day.ToString().PadLeft(2, '0') + d.Hour.ToString().PadLeft(2, '0') + d.Minute.ToString().PadLeft(2, '0');
//string FinalFileName= Path.Combine(GetPathFromBase("Upload\\Media"),"final-"+s+".jpg");
//rulMediaUpload.UploadedFiles[0].SaveAs(defaultTempFileName);
//FileInfo uploadedFile = new FileInfo(defaultTempFileName);
//uploadedFile.MoveTo(FinalFileName);
}
}
}
In both files the commented lines didn't cause any problems when not commented until... they did!
Please help me out here.