|
Subject:
|
Datalist ItemCommands
|
|
Posted By:
|
~Bean~
|
Post Date:
|
8/15/2006 8:37:00 AM
|
I am in the process of porting a 1.x project to 2.0. My problem is in a datalist I have - the ItemCommand, EditCommand, DeleteCommand, etc. are no longer firing. Not just the Code itself, but there is NO postback whatsoever. Any ideas why no postback?
<asp:datalist id="dlContact" runat="server" datakeyfield="id" OnItemCommand="dlContact_ItemCommand" OnEditCommand="Edit_Command" borderstyle="None">
<itemstyle borderstyle="None"></itemstyle>
<itemtemplate>
<asp:linkbutton id="Lbtnplayer_ID" Runat="server" CommandName="Select">Select</asp:linkbutton>
<asp:linkbutton text="Edit" commandname="Edit" runat="server" id="lnkEditContact" commandargument='1' />
</itemtemplate>
</asp:datalist>
============================================
Sub dlContact_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlContact.ItemCommand
Response.Write("Client Item Command: " & e.CommandName & " Argument: " & e.CommandArgument)
End Sub
the only thing I can think of is that the master page is somehow interfering with it...(?)
------------------------- Beware of programmers with screwdrivers...
|
|
Reply By:
|
Imar
|
Reply Date:
|
8/15/2006 9:04:54 AM
|
That's odd.
What does the final HTML in the browser look like?
Imar --------------------------------------- Imar Spaanjaars Everyone is unique, except for me. Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004 Want to be my colleague? Then check out this post.
|
|
Reply By:
|
~Bean~
|
Reply Date:
|
8/15/2006 9:10:50 AM
|
It look slike this:
<table id="ctl00_cpContent_dlContact" cellspacing="0" border="0" style="border-style:None;border-collapse:collapse;">
<tr>
<td style="border-style:None;">
<a id="ctl00_cpContent_dlContact_ctl00_Lbtnplayer_ID" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cpContent$dlContact$ctl00$Lbtnplayer_ID", "", true, "", "", false, true))">Select</a>
<a id="ctl00_cpContent_dlContact_ctl00_lnkEditContact" class="buttonTextandImg" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cpContent$dlContact$ctl00$lnkEditContact", "", true, "", "", false, true))">Edit</a>
</td>
</tr><tr>
<td style="border-style:None;">
<a id="ctl00_cpContent_dlContact_ctl01_Lbtnplayer_ID" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cpContent$dlContact$ctl01$Lbtnplayer_ID", "", true, "", "", false, true))">Select</a>
<a id="ctl00_cpContent_dlContact_ctl01_lnkEditContact" class="buttonTextandImg" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cpContent$dlContact$ctl01$lnkEditContact", "", true, "", "", false, true))">Edit</a>
</td>
</tr>
etc.
------------------------- Beware of programmers with screwdrivers...
|
|
Reply By:
|
Imar
|
Reply Date:
|
8/15/2006 9:17:30 AM
|
That looks pretty normal, I'd say.
I assume the code for WebForm_DoPostBackWithOptions is also present in your page?
With your previous 1.x code, did you get <a href> tags with a JavaScript function as well?
Imar --------------------------------------- Imar Spaanjaars Everyone is unique, except for me. Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004 Want to be my colleague? Then check out this post.
|
|
Reply By:
|
~Bean~
|
Reply Date:
|
8/15/2006 9:43:37 AM
|
Aha!
That was not the exact problem, but while looking over the source I noticed the js for a required field validator further up on the page. The page was not posting back because the validator was keeping it from doing so (and I had it hidden so I didn't even see it). All I needed was a tweak to that and it looks OK now...
Thanks Imar...
------------------------- Beware of programmers with screwdrivers...
|