Hi,
I have the following code and no matter what I do onclick event for button is not firing. I tried deleting the button, the pages. Redid the code. Moved the web project to a different computer and nothing. It worked a few hours ago.
Code on the web control .ascx:
The code on the .ascx.cs code page:
This user control gets loaded into a placeholder. Any help would be greatly appreciated.
I have the following code and no matter what I do onclick event for button is not firing. I tried deleting the button, the pages. Redid the code. Moved the web project to a different computer and nothing. It worked a few hours ago.
Code on the web control .ascx:
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AddNewPlaylist.ascx.cs" Inherits="WebControls_AddNewPlaylist" %>
Name your playlist: <asp:TextBox ID="PlayListNameTextBox" runat="server"></asp:TextBox><br />
Pick artwork for your playlist:<br />
<br />
Upload custom artwork:<br />
<asp:FileUpload ID="PlayListFileUpload" runat="server" /><br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br />
<asp:Label ID="StatusLabel" runat="server" Text=""></asp:Label>
Code:
protected void Button1_Click(object sender, EventArgs e)
{
string playListName = PlayListNameTextBox.Text;
Boolean fileOK = false;
String path = Server.MapPath("~/UserPages/PlayListImages/");
string imagePath;
if (PlayListFileUpload.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(PlayListFileUpload.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
}
if (fileOK)
{
try
{
PlayListFileUpload.PostedFile.SaveAs(path + PlayListFileUpload.FileName);
imagePath = path + PlayListFileUpload.FileName;
MusicDbBusinessTear.AddPlayList(playListName, imagePath);
StatusLabel.Text = "Playlist Created!";
Response.Redirect("~/UserPages/Music.aspx");
}
catch (Exception ex)
{
StatusLabel.Text = "Playlist could not be created.";
}
}
else
{
StatusLabel.Text = "Cannot accept files of this type.";
}
}
}
Comment