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

Accessing control properties in UplevelSelectorTemplate and ProgressTemplate Options
Gamz
#1 Posted : Thursday, October 06, 2011 2:00:58 PM
Rank: Newbie

Groups: Registered

Joined: 10/4/2011
Posts: 4

Hi again,

I'm trying to dynamically set the text of the "Add File" button in the <UplevelSelectorTemplate>. The reason for this is our website is bilingual, and I need to dynamically change the text to another language based on the culture instead of having the button's text hard-coded.

I've tried using FindControl within the ItemTemplateCreated method, but the button can't be found (likely because it's not in the template?)

My code is below. I am trying to set the text for btnAddFile

Something like this:

 

                Dim btnAddFile As Button = DirectCast(e.Item.FindControl("btnAddFile"), Button)

                If clsCulture.CurrentCulture = clsUtil.AvailableLanguages.fr Then
                    btnAddFile.Text = "Ajouter un fichier"
                Else
                    btnAddFile.Text = "Add File"
                End If

 

I also need to do this for controls inside the <ProgressTemplate> as well (ie: label control for "Uploading", "(calculating"), "currently uploading", etc). I need create this text as labels and translate the text depending on the culture.

 

 

My markup code... thank you:

 

<kw:SlickUpload ID="SlickUpload1" runat="server" ShowDuringUploadElements="cancelButton" MaxFiles="1" HasPostProcessStep="True" HideDuringUploadElements="cmdUpload" ValidExtensions="" OnUploadComplete="SlickUpload1_UploadComplete" AutoPostBackAfterUpload="true" >

                <DownlevelSelectorTemplate>

                    <input type="file" id="fuFile" />

                </DownlevelSelectorTemplate>

                <UplevelSelectorTemplate>

                    <!-- NEED TO ACCESS THIS BUTTON-->
                            <asp:Button ID="btnAddFile" runat="server" Text="Add File" /> 

                </UplevelSelectorTemplate>

                <FileTemplate>

                    <kw:FileListRemoveLink ID="FileListRemoveLink1" runat="server">[X]</kw:FileListRemoveLink>

                    <kw:FileListFileName ID="FileListFileName1" runat="server" />

                    <kw:FileListValidationMessage ID="FileListValidationMessage1" runat="server" ForeColor="Red" />

                </FileTemplate>

                <ProgressTemplate>

 

                    <table width="100%">

                        <tr>

                            <td>
                               <!--NEED TO ACCESS THIS LABEL -->
                                       <asp:label id="lblUploading" runat="server" text="Uploading" /> 

                                <kw:UploadProgressElement ID="UploadProgressElement1" runat="server" Element="FileCountText">

                                </kw:UploadProgressElement>

                                ,

                                <kw:UploadProgressElement ID="UploadProgressElement2" runat="server" Element="ContentLengthText">

                                    (calculating)</kw:UploadProgressElement>

                                .

                            </td>

                        </tr>

                         {...}

 

                </ProgressTemplate>

            </kw:SlickUpload>

 

Axosoft
#2 Posted : Friday, October 07, 2011 10:33:26 AM
Rank: Administration


Groups: Administrators

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

Have you tried using the ASP.NET Localization syntax? This is what we usually suggest for localizing SlickUpload: http://msdn.microsoft.com/en-us/magazine/cc163566.aspx

Something like:

<asp:Label ID="lblApplicationName" runat="server" 
    Text="<%$ Resources:Litware, ApplicationName %>" /> 

 

Gamz
#3 Posted : Friday, October 07, 2011 11:17:36 AM
Rank: Newbie

Groups: Registered

Joined: 10/4/2011
Posts: 4

ChrisHynes wrote:

Have you tried using the ASP.NET Localization syntax? This is what we usually suggest for localizing SlickUpload: http://msdn.microsoft.com/en-us/magazine/cc163566.aspx

Something like:

<asp:Label ID="lblApplicationName" runat="server" 
    Text="<%$ Resources:Litware, ApplicationName %>" /> 

 

 

 

Thank you for your suggestion. The website is currently using the Enterprise Localization Toolkit, which would not register the keys when I added them to the nested controls.

I ended up finding a work-around, and just generated a local resource file for only the user control. Seems to work just fine. 

Thanks for the help!

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.