Hi Guys,
I am having a hell of a time trying to figure this out..
I have a major issue that is effecting all of my web parts.
I have a main page, and then in that page i have several controls all based off off of the same code template.
If figure they are all suffering from the same event wireup problem so it I can fix one then I can fix them all.
So, to start let me explain the layout.
There is a main page aspx page.. on this page there is a web control included..
On this web control, there are a few update panels, and inside one of those panels their is a listview with a template and in its template each row item has some call back buttons to manage them.
Now, when I first load this page.. IE start up my visual studio web server and navigate to this page and then click one of these row buttons..
The call back makes it to the server, and the init is fired but the event of the button that was clicked never fires.
Now, here is where it gets weird.. click a couple more times and then it starts to fire as expected.
Code below.
<%@ Page
Language="C#"
AutoEventWireup="True"
CodeBehind="/Members/Default.aspx.cs"
Inherits="TheScene.Web.MusicProfileEditor.BandEditor"
Theme="Scene2"
MasterPageFile="/MonoX/MasterPages/ThePittsburghSceneHeader2.master"
%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ MasterType TypeName="MonoSoftware.MonoX.BaseMasterPage" %>
<%@ Import Namespace="MonoSoftware.MonoX.Resources" %>
<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %>
<%@ OutputCache Location="None" VaryByParam="None" %>
<%@ Register TagPrefix="Editor" TagName="MusicEditor" Src="/Members/BandEditor/SongEditor.ascx" %>
<%@ Register TagPrefix="PE" TagName="ProfileEditor" Src="/Members/BandEditor/ProfileEditor.ascx" %>
<%@ Register TagPrefix="EM" TagName="EventEditor" Src="/Members/BandEditor/EventEditor.ascx" %>
<%@ Register TagPrefix="IMG" TagName="ProfileImageEditor" Src="/Members/BandEditor/ProfileImageEditor.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cp" runat="server">
<link rel="stylesheet" href="../MonoX/Scripts/css/jquery.Jcrop.css" type="text/css" />
<div class="page_header"><h97>Band Editor</h97></div>
<div class="page_box">
<cc1:TabContainer ID="TabContainer1" runat="server">
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Picture">
<ContentTemplate>
<IMG:ProfileImageEditor runat="server" ID="ProfileImageEditor" />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="Music">
<ContentTemplate>
<Editor:MusicEditor runat="server" ID="SongEditor" />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel runat="server" HeaderText="Profile">
<ContentTemplate>
<PE:ProfileEditor runat="server" ID="ProfileEditor" />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Events">
<ContentTemplate>
<EM:EventEditor runat="server" ID="EventEditor" />
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</div>
</asp:Content>
<asp:UpdatePanel ID="UpdateShellPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdatePanel ID="PlaySong" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
</asp:UpdatePanel>
<!-- Start: Main Player Panel -->
<asp:UpdatePanel ID="MainPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table bgcolor="lightgreen" border="1">
<tr>
<th>Release Year</th>
<th>Album Title</th>
<th>Track #</th>
<th>Song Title</th>
<th>Artist</th>
<th></th><th></th><th></th>
<asp:ListView ID="ListViewSongs" runat="server"
onitemdatabound="ListViewSongs_ItemDataBound" >
<LayoutTemplate>
<ul class="AlbumList">
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</ul>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("ReleaseYear", "{0:d}")%></td>
<td><%# Eval("AlbumName") %></td>
<td><%# Eval("TrackNumber") %></td>
<td><%# Eval("SongTitle") %></td>
<td><%# Eval("ArtistName") %></td>
<td>
<asp:Button id="EditSong" runat="server" class="clsbtn"
CommandArgument='<%# Eval("SongId") %>' CommandName="EditSong" OnClick="SongBtnHandler" Text="Edit" />
</td>
<td>
<asp:Button ID="Play" runat="server" Text='Play' CommandArgument='<%# Eval("SongId") %>' />
<%-- ClientIDMode="AutoID" <asp:button id="Play" runat="server" class="clsbtn" UseSubmitBehavior="false"
CommandArgument='<%# Eval("SongId") %>' CommandName="PlaySong" OnClick="PlayerBtnHandler" Text="PLAY" />
--%> </td>
<td>
<asp:Button id="DeleteSong" runat="server" class="clsbtn"
CommandArgument='<%# Eval("SongId") %>' CommandName="DeleteSong" OnClick="SongBtnHandler" Text="X" />
<AJX:ConfirmButtonExtender ID="DeleteSong_ConfirmButtonExtender"
runat="server" ConfirmText= 'Are you sure you want to delete this song ? ' Enabled="True" TargetControlID="DeleteSong">
</AJX:ConfirmButtonExtender>
</td>
</tr>
</ItemTemplate>
<EmptyDataTemplate>
<div>No Songs</div>
</EmptyDataTemplate>
</asp:ListView>
</tr>
</table>
<br>
<asp:Button ID="Uploader1Insert" runat="server" AlternateText="Upload Song" onclick="Uploader1Insert_Click" Text="Upload Song (MP3)" Width="142px" />
<asp:UpdatePanel ID="UploadSongPanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="Uploader1ProgressText" runat="server"></asp:Label>
<asp:Button ID="Uploader1Cancel" runat="server" AlternateText="Cancel" Height="25px" Text="Cancel Upload" Width="139px" onclick="Uploader1Cancel_Click1" />
<CuteWebUI:Uploader ID="Uploader1" runat="server" CancelButtonID="Uploader1Cancel" InsertButtonID="Uploader1Insert"
MultipleFilesUpload="false" OnFileUploaded="Uploader_FileUploaded" ProgressCtrlID="Uploader1Progress"
ProgressTextID="Uploader1ProgressText"><ValidateOption MaxSizeKB="10240" />
</CuteWebUI:Uploader>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
<!-- End: Main Panel-->
<asp:UpdatePanel ID="EditSongPanel" runat="server" Visible="False" UpdateMode="Conditional">
<ContentTemplate>
<p>Artist Name:</p><p><asp:TextBox ID="txtArtistName" runat="server" Width="523px"></asp:TextBox></p>
<p>Song Title:</p><p><asp:TextBox ID="txtSongTitle" runat="server" Width="523px"></asp:TextBox></p>
<p>Album Name:</p><p><asp:TextBox ID="txtAlbumName" runat="server" Width="523px"></asp:TextBox></p>
<p>Track Number:</p><p><asp:TextBox ID="txtTrackNumber" runat="server" Width="523px"></asp:TextBox></p>
<p>Release Year:</p><p><asp:TextBox ID="txtReleaseYear" runat="server" Width="523px"></asp:TextBox></p>
<p>
<%--<asp:Button ID="CancelEditCmd" runat="server" onclick="EdidCancelCmd_Click" Text="Cancel" />--%>
<asp:Button ID="EditSaveCmd" runat="server" onclick="EditSaveCmd_Click" Text="Save" />
</p>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
Code behind control.. little slimmed down but core is therem
namespace TheScene.Web.WebParts
{
public partial class MusicEditor : BasePagedPart
{
#region Constructor
/// <summary>
/// Constructor.
/// </summary>
public MusicEditor()
{
Title = "Music Editor";
IsTemplated = false;
// ControlSpecificTemplateSubPath = "";
}
#endregion
#region Page Events
protected void Page_Init(object sender, EventArgs e)
{
//custom events handlers ? - was playing with this to try to solve issue.
Page.LoadComplete += new EventHandler(Page_LoadComplete);
ListViewSongs.ItemCommand += new EventHandler<ListViewCommandEventArgs>(ListView1_ItemCommand);
}
protected void Page_PreRender(object sender, EventArgs e)
{
}
void Page_LoadComplete(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
PopulateSongList();
MainPanel.Update();
}
}
#endregion
#region Methods
/// <summary>
/// Apply web part property changes (Note: Overridden property still needs to be marked as <see cref="MonoSoftware.MonoX.WebPartApplyChangesAttribute"/>).
/// <para>
/// Note: Marked with <see cref="MonoSoftware.MonoX.WebPartApplyChangesAttribute"/> attribute so it is called from ApplyChanges event in the editor part to refresh the module appearance.
/// </para>
/// </summary>
///
[WebPartApplyChanges]
public override void ApplyChanges()
{
base.ApplyChanges();
}
#endregion
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
int songid = Convert.ToInt32(e.CommandArgument.ToString());
StreamMusic(songid);
}