2

I have ext:FileUploadField on the page. After file upload I need to show a link to this file. I dynamically create a LinkButton, add it on the Panel1, and I can't see the the LinkButton! I dunno why!

<ext:Panel ID="Panel1" runat="server"> 
    <Content> 
        <ext:FileUploadField ID="FileUploadField1" runat="server" EmptyText="Choose a file" FieldLabel="File" Icon="ImageAdd" /> 
    </Content> 
    <Buttons> 
        <ext:Button ID="SaveButton2" runat="server" Text="Upload"> 
            <DirectEvents> 
                <Click OnEvent="UploadClick"></Click> 
            </DirectEvents> 
        </ext:Button> 
    </Buttons> 
</ext:Panel> 


protected void UploadClick(object sender, DirectEventArgs e) 
        { 
            if (this.FileUploadField1.HasFile) 
            { 
                var attachment = new Attachment { ............ }; 
                if (UploadAttachment(attachment)) 
                { 
                    X.Msg.Show( ...... ); 

                    var linkButton = new LinkButton(); 
                    linkButton.ID = "fdsfdsfds"; 
                    linkButton.Text = attachment.Name; 
                    linkButton.NavigateUrl = "#"; 
                    linkButton.Render(); 
                    Panel1.Add(linkButton); 
                    // Panel1.Render(true); 
                     Panel1.DoLayout(true,true); 
                } 
                else 
                { 
                   //................ 
                } 

            } 
            else 
            { 
                //................ 
            } 
        }
JamesHalsall
  • 13,224
  • 4
  • 41
  • 66
Alexandre
  • 13,030
  • 35
  • 114
  • 173

2 Answers2

1

I am guessing you need to add it to the buttons list of the Panel not to the panel itself. You may also have a layout issue if you have fit layout and adding a second item, that wont work.

dbrin
  • 15,525
  • 4
  • 56
  • 83
0

Try to use this code:

X.Msg.Show( ...... ); 
var linkButton = new LinkButton(); 
linkButton.ID = "fdsfdsfds"; 
linkButton.Text = attachment.Name; 
linkButton.NavigateUrl = "#"; 
linkButton.Render(Panel1, RenderMode.AddTo);

This will add link button directly to Panel1

Baidaly
  • 1,829
  • 1
  • 15
  • 16