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

Create SlickUpload Control programmatically Options
Gamz
#1 Posted : Tuesday, October 04, 2011 1:02:05 PM
Rank: Newbie

Groups: Registered

Joined: 10/4/2011
Posts: 4

Hi all,

First of all, great product - thank you :)

I've done some searching and I can't find an example of creating the SlickUpload control programmatically? I'm trying to implement SlickUpload on a form that is dynamically created from a CMS. 

I haven't gotten too far yet, but here is a sample of what I'm trying to do, and I'm not sure what components I'm missing. 

 

 

Dim ControlHolder As PlaceHolder = New PlaceHolder

        Dim MyControl As WebControl
        Select Case Trim(UCase(MyDetail.DataType))
            Case "TEXT"
                MyControl = New TextBox
                MyControl.TabIndex = MyTabIndex
                MyControl.ID = MyDetail.DataType & "_" & MyDetail.StepDetailID
{...}

            Case "MULTILINE"
                    MyControl = New TextBox
                    MyControl.TabIndex = MyTabIndex
                    MyControl.ID = MyDetail.DataType & "_" & MyDetail.StepDetailID
{...}

            Case "SELECT", "LIST"
                    Dim CurControl As ListControl
                    If Trim(UCase(MyDetail.DataType)) = "SELECT" Then
                        CurControl = New DropDownList
                    Else
                        CurControl = New ListBox
                    End If
                 {...}

                MyControl = CurControl

            Case "CHECKBOX"
                MyControl = New CheckBox
                MyControl.TabIndex = MyTabIndex
                MyControl.ID = MyDetail.DataType & "_" & MyDetail.StepDetailID
               {...}

            Case "LARGEFILEUPLOAD"

                'Create Upload button
                Dim btnUpload As New Button
                btnUpload.ID = "cmdUpload"
                btnUpload.Text = "Upload"

                'Create Cancel button
                Dim btnCancel As New Button
                btnCancel.ID = "cancelButton"
                btnUpload.Text = "Cancel"

                ControlHolder.Controls.Add(btnCancel)

                'Create Large File Upload component
                Dim objLFU As New Controls.SlickUpload
                objLFU.TabIndex = MyTabIndex
                objLFU.ID = MyDetail.DataType & "_" & MyDetail.StepDetailID

                objLFU.ValidExtensions = MyDetail.UploadValidExtension
                objLFU.MaxFiles = 1
                objLFU.HasPostProcessStep = True
                objLFU.ShowDuringUploadElements = "cancelButton"
                objLFU.HideDuringUploadElements = "cmdUpload"

                MyControl = objLFU

            Case Else
                MyControl = New Label   'if not supported, return an empty label
        End Select

        ControlHolder.Controls.Add(MyControl)

 

Axosoft
#2 Posted : Tuesday, October 04, 2011 1:17:34 PM
Rank: Administration


Groups: Administrators

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

Could you put the SlickUpload control code inside a .ascx, and then use LoadControl to load that programmatically? That's probably the simplest way.

The other alternative is to put each template in its own .ascx, and then load the templates like so:

objLFU.SelectorTemplate = LoadControl("~/selector.ascx")

etc.

Gamz
#3 Posted : Tuesday, October 04, 2011 1:22:50 PM
Rank: Newbie

Groups: Registered

Joined: 10/4/2011
Posts: 4

ChrisHynes wrote:

Could you put the SlickUpload control code inside a .ascx, and then use LoadControl to load that programmatically? That's probably the simplest way.

The other alternative is to put each template in its own .ascx, and then load the templates like so:

objLFU.SelectorTemplate = LoadControl("~/selector.ascx")

etc.

Thank you for your prompt response. Sometimes it's easy to lose sight of the trees from the forest. I have no idea why I didn't think of putting it in a user control. Thank you again. 

 

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.