Rank: Member
Groups: Member
Joined: 2/12/2010(UTC) Posts: 17
|
I am using the Aurigma Dual ImageUploader control within ASP.NET. I have found documents on how to maintain the session state when the Java version of the control is being used. However, I am having a problem with determining which version of the control is being used within javascript so that I can execute the proper AddCookies() command if the Java control is being used. Here is the code I am using: Code:
<script type="text/javascript">
function ClientBeforeUpload() {
var iu = getImageUploader("<%=ImageUploader1.ClientID%>");
if (iu.getControlType() == "Java")
iu.AddCookie('<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' +
'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>');
}
</script>
<cc1:ImageUploader ID="ImageUploader1" name="ImageUploader1" runat="server" Height="400"
LicenseKey="71060-4698C-00000-05AD1-8C271;72060-4698C-00000-00CD8-D244C" Width="600"
OnFileUploaded="ImageUploader1_FileUploaded" ShowDebugWindow="true" OnClientBeforeUpload="ClientBeforeUpload"
ActiveXControlEnabled="true">
</cc1:ImageUploader>
When the ClientBeforeUpoad function runs it fails on the getControlType() method with an "object doesn't support this property or method" error. Can anyone see what I am doing wrong here?
|
|
|
|
Rank: Member
Groups: Member
Joined: 2/12/2010(UTC) Posts: 17
|
btw...I am using version 6.1.4.19258 of the control
|
|
|
|
Rank: Advanced Member
Groups: Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hello Scott, Actually Image Uploader ASP.NET control can preserve cookies automatically. You just need to use PreserveHttpCookies property: Code:PreserveHttpCookies = "true"
In this case you do not need to use OnClientBeforeUpload property. To get more information about this property click here: PreserveHttpCookies Property |
|
|
|
|
Rank: Member
Groups: Member
Joined: 2/12/2010(UTC) Posts: 17
|
Thanks for the reply. The reason I started investigating how to preserve the http cookies was because when I forced the ImageUploader control to use the Java version it was redirecting to my login page when I tried to upload a file. The default value of that PreserveHttpCookies property is True, but I tried setting it to True anyways and it did not make a difference. When forcing the ImageUploader control to use the Java version I was able to get it to work by using this function on the OnClientBeforeUpload event: Code:
<script type="text/javascript">
var iu = getImageUploader("<%=ImageUploader1.ClientID%>");
iu.AddCookie('<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' +
'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>');
</script>
I removed the check to see whether or not the Java or ActiveX control was loaded since I knew the Java control was going to be loaded. This seemed to work fine and the Java control was no longer causing a redirect to my login page, which was in turn causing an error. However, I do want to use the ActiveX and Java controls. I'm not sure why the PreserveHttpCookies property is not working, but it does not appear to be. Executing the above javascript does seem to work. Any help would be greatly appreciated.
|
|
|
|
Rank: Advanced Member
Groups: Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hi, You can try to use instead of if (iu.getControlType() == "Java") th following code: Quote:I'm not sure why the PreserveHttpCookies property is not working Could you please describe it a bit detailed. By the way Image Uploader 6.5 version is already available. Did you try it? |
|
|
|
|
Rank: Member
Groups: Member
Joined: 2/12/2010(UTC) Posts: 17
|
I just downloaded the 6.5 version and installed it. It did not affect this issue however. I am using ASP.NET 3.0. My application is using forms authentication. I am using the ImageUploader control on a User Control (.ascx). That User Control is usually embedded in another user control when it is used. If I force the ImageUploader control to use the Java version (by setting ActiveXControlEnabled="false") when I attempt to upload an image I get the error "The server attempted to redirect you to {login page}, but server redirects are not supported." I have set PreserveHttpCookies="true". I have also tried the following code: Code:
<script type="text/javascript">
function ClientBeforeUpload() {
var iu = getImageUploader("<%=ImageUploader1.ClientID%>");
if (iu.addCookie())
iu.addCookie('<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' +
'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>');
}
</script>
<cc1:ImageUploader ID="ImageUploader1" name="ImageUploader1" runat="server" Height="400"
LicenseKey="71060-4698C-00000-05AD1-8C271;72060-4698C-00000-00CD8-D244C" Width="600"
OnFileUploaded="ImageUploader1_FileUploaded" ShowDebugWindow="true"
ActiveXControlEnabled="false" PreserveHttpCookies="true" OnClientBeforeUpload="ClientBeforeUpload">
</cc1:ImageUploader>
Upon clicking the Send button on the ImageUploader control this gives me the following javascript error: Line: 2820 Error: java.lang.IllegalArgumentException: No method found matching name AddCookie and arguments [] So it is failing on the if (iu.addCookie()) check. If I replace that check with: if (iu.getControlType() == "Java") I get the following javascript error: Line: 2820 Error: Object doesn't support this property or method However, if I replace the entire javascript function with the following, everything works fine: Code:
function ClientBeforeUpload() {
var iu = getImageUploader("<%=ImageUploader1.ClientID%>");
iu.addCookie('<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' +
'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>');
}
However, this isn't doing any checking to see which version of the control (ActiveX or Java) is running. I am not sure of the implications of adding the cookie if the ActiveX version of the control is running. I am testing all of this on IE 8.
|
|
|
|
Rank: Advanced Member
Groups: Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hi, I just tested the following code and it worked well: Code:function ClientBeforeUpload() {
var iu = getImageUploader("<%=ImageUploader1.ClientID%>");
if (<%= ImageUploader1.JavaScriptWriterVariableName %>.getControlType() == "Java") {
iu.addCookie('<%= FormsAuthentication.FormsCookieName %>=<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>;' +
'ASP.NET_SessionId=<%= Request.Cookies["ASP.NET_SessionId"].Value %>');
}
}
Please try it. |
|
|
|
|
Rank: Member
Groups: Member
Joined: 2/12/2010(UTC) Posts: 17
|
That does appear to fix the problem. No more redirects to the login page when using the Java control.
Thank You!
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.