SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Internationalization of ProgressTemplate with kw:UploadProgressElement Options
dougdomeny
#1 Posted : Tuesday, October 11, 2011 10:05:02 AM
Rank: Newbie


Groups: Registered

Joined: 10/11/2011
Posts: 4
Location: Manchester, NH, USA

I'm trying to internationalize a ProgressTemplate using String.Format and kw:UploadProgressElement.

Example,

WITHOUT internationalization (I18N)

<kw:SlickUpload ...>

<ProgressTemplate>

Currently uploading: <kw:UploadProgressElement ID="CurrentFileName" runat="server" Element="CurrentFileName" />
, file <kw:UploadProgressElement ID="CurrentFileIndex" runat="server" Element="CurrentFileIndex">&nbsp;</kw:UploadProgressElement>
 of <kw:UploadProgressElement ID="FileCount" runat="server" Element="FileCount" />.

WITH I18N using String.Format and my own Format.Render method that renders a control as a string.

<%= String.Format("Currently uploading: {0}, file {1} of {2}.", Format.Render(CurrentFileName), Format.Render(CurrentFileIndex), Format.Render(FileCount))%>
<kw:UploadProgressElement ID="CurrentFileName" runat="server" Element="CurrentFileName" />
<kw:UploadProgressElement ID="CurrentFileIndex" runat="server" Element="CurrentFileIndex">&nbsp;</kw:UploadProgressElement>
<kw:UploadProgressElement ID="FileCount" runat="server" Element="FileCount" />

This would work except for one problem. The kw:UploadProgressElement controls are not created as part of the page because they are in the ProgressTemplate:ITemplate.

If the kw:UploadProgressElement controls are moved outside the <kw:SlickUpload> control, an error occurs stating the need for the ProgressDisplayId attribute. So I added it, which fixed the error, but then the SlickUpload does not update the values during upload--I suspect it isn't looking for a control with ProgressDisplayId. I could not find any documentation on ProgressDisplayId, so I don't know how to use it.

Any thoughts on how to accomplish internationalization? Or, use kw:UploadProgressElement with ProgressDisplayId that is outside the ProgressTemplate element?

 

Axosoft
#2 Posted : Tuesday, October 11, 2011 10:15:58 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Hmm. We usually suggest using the ASP.NET localization using <%$ %> to pull resources (http://msdn.microsoft.com/en-us/library/ms227427.aspx), but it sounds like you've got a more advanced architecture set up there.

Here's a thought. Can you put the progress template in a user control, and then load it using LoadTemplate()? I believe this should let you access the controls at that point. To do this, you'd put everything that is currently in <ProgressTemplate> in a new usercontrol, say "SlickUploadProgressTemplate.ascx". Then in your Page_Load, you can pull it in using:

slickUpload.ProgressTemplate = LoadTemplate("~/SlickUploadProgressTemplate.ascx");

Let me know if that works. If not, there are a couple of other methods we can try.

Just to make sure we're on the same page, which version of SlickUpload are you using?

dougdomeny
#3 Posted : Tuesday, October 11, 2011 10:30:03 AM
Rank: Newbie


Groups: Registered

Joined: 10/11/2011
Posts: 4
Location: Manchester, NH, USA
Thanks for your quick reply.

If the contents of ProgressTemplate are not in kw:SlickUpload, the following error appears when viewing the web page:

ProgressElement must either be contained in a ProgressDisplay or have a ProgressDisplayId set.

SlickUpload version 5.5.11
Axosoft
#4 Posted : Wednesday, October 12, 2011 11:43:18 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Have you tried setting the ProgressDisplayId manually? If you view source on the page and search for "progressDisplay", you should come up with the id of the control. It'll be something like slickUpload1_progressDisplay (depending on page hierarchy and the id of your SlickUpload control). You should be able to set the ProgressDisplayId property on the ProgressElement to that control id.

dougdomeny
#5 Posted : Thursday, October 13, 2011 9:39:33 AM
Rank: Newbie


Groups: Registered

Joined: 10/11/2011
Posts: 4
Location: Manchester, NH, USA

Thanks! That works, though the ProgressDisplayId is ugly and fragile.

<kw:UploadProgressElement ID="CurrentFileName" ProgressDisplayId="ctl00_ctl00_MainContent_TheSlickUploadControl_progressDisplay" runat="server" Element="CurrentFileName" />                                            <kw:UploadProgressElement ID="CurrentFileIndex" ProgressDisplayId="ctl00_ctl00_MainContent_TheSlickUploadControl_progressDisplay" runat="server" Element="CurrentFileIndex" />                                            <kw:UploadProgressElement ID="FileCount" ProgressDisplayId="ctl00_ctl00_MainContent_TheSlickUploadControl_progressDisplay" runat="server" Element="FileCount" />

Binding to the control's ClientID is a bit cleaner.

<kw:UploadProgressElement ID="CurrentFileName" ProgressDisplayId='<%# TheSlickUploadControl.ClientID + "_progressDisplay" %>' runat="server" Element="CurrentFileName" /> <kw:UploadProgressElement ID="CurrentFileIndex" ProgressDisplayId='<%# TheSlickUploadControl.ClientID + "_progressDisplay" %>' runat="server" Element="CurrentFileIndex" /> <kw:UploadProgressElement ID="FileCount" ProgressDisplayId='<%# TheSlickUploadControl.ClientID + "_progressDisplay" %>' runat="server" Element="FileCount" />

Alternatively, I had manually rendered the elements because they are simple span tags.

<div><%= String.Format("Currently uploading: {0}, file {1} of {2}.""<span id='CurrentFileName'</span>",
    "<span id='CurrentFileIndex'></span>""<span id='FileCount'></span>")%></div>

<div style="displaynone"> <kw:UploadProgressElement ID="CurrentFileName" ClientIDMode="Static" runat="server" Element="CurrentFileName" /> <kw:UploadProgressElement ID="CurrentFileIndex" ClientIDMode="Static" runat="server" Element="CurrentFileIndex" /> <kw:UploadProgressElement ID="FileCount" ClientIDMode="Static" runat="server" Element="FileCount" />
</
div>

With my approach, I have to use static client ids, which are duplicates. Duplicate IDs are not valid HTML. My approach is also ugly and fragile.

I'll use your approach, which overall is more robust. Thanks again.

Axosoft
#6 Posted : Thursday, October 13, 2011 9:46:29 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Sounds good.

The ProgressDisplayId issue is a known problem with SlickUpload 5. SlickUpload 6 has a better implementation that binds the other direction, so the progress display discovers the elements rather than the elements connecting to the progress display.

Users browsing this topic
Guest
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.