<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblDummy" runat="server" EnableViewState="false" Style="display: none;"></asp:Label>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" /><br />
<asp:Panel ID="pnlConfirmation" runat="server" Width="300px" Style="display: none;"
CssClass="ModalPopupFront">
<asp:Label ID="lblPopupHeader" runat="server" Text="Confirmation" Style="background-color: Blue;
color: #ffffff; font-size: 14px;"></asp:Label><br />
<br />
<asp:Label ID="lblConfirmationMessage" runat="server" Text="This file already exists, are you sure you want to OverWrite it?"></asp:Label><br />
<br />
<asp:Button ID="btnOverwrite" runat="server" Text="Overwrite" OnClick="btnOverwrite_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Don't Overwrite" OnClick="btnCancel_Click" />
</asp:Panel>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" Enabled="False" TargetControlID="lblDummy"
PopupControlID="pnlConfirmation" BackgroundCssClass="ModalPopupBack" DropShadow="true">
</cc1:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>
protected void btnUpload_Click(object sender, EventArgs e)
{
//replace the following line with the actual file check
bool fileExists = true;
//if file already exists
if (fileExists)
{
this.ModalPopupExtender1.Enabled = true;
this.ModalPopupExtender1.Show();
}
else //if file does not exist
{
//Continue to save the file
}
}
protected void btnOverwrite_Click(object sender, EventArgs e)
{
//Save the file to overwrite the old one.
}
protected void btnCancel_Click(object sender, EventArgs e)
{
this.ModalPopupExtender1.Hide();
}
.ModalPopupBack
{
background-color:#666;
}
.ModalPopupFront
{
background-color:#fff;
border:outset 2px #000;
padding-left:2px;
padding-right:2px;
padding-top:4px;
padding-bottom:4px;
line-height: 18px;
}
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)