Here is an exemple of the problem. It's derived from simple-upload-UI.aspx.
Modification of simple-upload-UI.aspx :
The forms begins now with a simple button.
All the old part of the form is placed into a MultiView/View.
Initialy, the multiview have its visible attribute set to false.
The callback of the first button sets the visible attribute of the multiview to true.
Prolem with the new code :
After the first clic on the button. the old form appear. OK
The first use of image upload is normal. OK
Now, the association of "InsertButtonID='Uploader1Insert'" is lost. NON OK
The original text button of Uploader1 appear. NON OK
Code :
<%@ Page Language="C#" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
script runat="server">
void InsertMsg(string msg)
{
ListBoxEvents.Items.Insert(0, msg);
ListBoxEvents.SelectedIndex = 0;
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
SampleUtil.SetPageCache();
Uploader1.FileUploaded +=
new UploaderEventHandler(Uploader_FileUploaded);
ButtonPostBack.Click +=
new EventHandler(ButtonPostBack_Click);
}
void ButtonPostBack_Click(object sender, EventArgs e)
{
InsertMsg(
"You clicked a PostBack Button.");
}
void Uploader_FileUploaded(object sender, UploaderEventArgs args)
{
Uploader uploader = (Uploader)sender;
InsertMsg(
"File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");
//Copys the uploaded file to a new location.
//args.CopyTo(path);
//You can also open the uploaded file's data stream.
//System.IO.Stream data = args.OpenStream();
}
protected void Page_Load(object sender, EventArgs e)
{
}
void MakeVisible_Click(object sender, EventArgs args)
{
MultiView1.Visible =
true;
}
</script>
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Simple Upload Into MultiView/View</title>
<link rel="stylesheet" href="demo.css" type="text/css" />
</
head>
<
body>
<form id="form1" runat="server">
<asp:ScriptManager ID="Scriptmanager1" runat="server">
</asp:ScriptManager>
<p><asp:Button ID="MakeVisible" runat="server" Text="Make Visible" OnClick="MakeVisible_Click"/></p>
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0" Visible="false">
<asp:View ID="View1" runat="server">
<div class="content">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<h2>Simple Upload (Customizing the UI) </h2>
<p>A sample demonstrating how to customize the look and feel of file upload controls. (Maximum file size: 10M).
</p>
<asp:Image runat="server" ID="Uploader1Insert" AlternateText="Upload File"
ImageUrl="~/sampleimages/upload.png" />
<asp:Panel runat="server" ID="Uploader1Progress" BorderColor="Orange" BorderStyle="dashed"
BorderWidth="2" Style="PADDING-RIGHT: 4px;PADDING-LEFT: 4px;PADDING-BOTTOM: 4px;PADDING-TOP: 4px">
<asp:Label id="Uploader1ProgressText" runat="server" ForeColor="Firebrick"></asp:Label>
</asp:Panel>
<asp:Image runat="server" ID="Uploader1Cancel" AlternateText="Cancel" ImageUrl="~/sampleimages/cancel_button.gif" />
<CuteWebUI:Uploader runat="server" ID="Uploader1"
InsertButtonID='Uploader1Insert'
ProgressCtrlID='Uploader1Progress'
ProgressTextID='Uploader1ProgressText'
CancelButtonID='Uploader1Cancel'>
<VALIDATEOPTION MaxSizeKB="10240" />
</CuteWebUI:Uploader>
<br /><br />
<div>
Server Trace:
<br><br>
<asp:ListBox runat="server" ID="ListBoxEvents" Width="400"></asp:ListBox>
</div>
<br><br>
<asp:Button ID="ButtonPostBack" Text="This is a PostBack button" runat="server"/>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:View></asp:MultiView>
</form>
</
body>
</html>
Thank's a lot
André