Aug 12, 2011, 7:46 AM
Dynamically add LinkButton on Panel
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
{
//................
}
}