Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2006, 08:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default Datalist ItemCommands

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?

Code:
<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...
__________________
-------------------------
Beware of programmers with screwdrivers...
 
Old August 15th, 2006, 09:04 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old August 15th, 2006, 09:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

It look slike this:
Code:
<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(&quot;ctl00$cpContent$dlContact$ctl00$Lbtnplayer_ID&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Select</a>
            <a id="ctl00_cpContent_dlContact_ctl00_lnkEditContact" class="buttonTextandImg" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cpContent$dlContact$ctl00$lnkEditContact&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, 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(&quot;ctl00$cpContent$dlContact$ctl01$Lbtnplayer_ID&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Select</a>
            <a id="ctl00_cpContent_dlContact_ctl01_lnkEditContact" class="buttonTextandImg" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cpContent$dlContact$ctl01$lnkEditContact&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))">Edit</a>                        
        </td>
    </tr>

    etc.
-------------------------
Beware of programmers with screwdrivers...
 
Old August 15th, 2006, 09:17 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old August 15th, 2006, 09:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 100
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to ~Bean~
Default

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...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datalist inside datalist amit.jagtap ASP.NET 2.0 Professional 1 September 4th, 2007 05:03 AM
Datalist cp75 ASP.NET 1.0 and 1.1 Professional 10 September 8th, 2006 11:38 AM
DataList in DataList acko ASP.NET 1.0 and 1.1 Professional 3 July 9th, 2004 05:18 PM
about datalist bvrao VS.NET 2002/2003 0 December 24th, 2003 06:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.