Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're using the wrong <code>DisplayMode</code> for your <code>BulletedList</code> control. You should use a <code>DisplayMode</code> of <code>LinkButton</code>. When you use <code>DisplayMode.HyperLink</code>:</p> <blockquote> <p>Users can click links to move to another page. You must provide a target URL as the Value property of individual items.</p> </blockquote> <p>This is from the <a href="http://msdn.microsoft.com/en-us/library/ms228101.aspx" rel="noreferrer">MSDN docs</a> for this control. (It's about 3/4 of the way down the page.)</p> <p>When you use a <code>BulletedList</code> control in <code>HyperLink</code> mode, the value of your <code>ListItem</code> is the URL that you're navigating to. So your static page HTML controls would use <code>ListItem.Value</code> as the <code>href</code> attribute of the <code>&lt;a&gt;</code> tag.</p> <p>Here's what the HTML markup looks like when you use a DisplayMode of HyperLink (it's a plain old HTML anchor tag w/ a href):</p> <pre><code>&lt;li&gt;&lt;a href="1"&gt;One&lt;/a&gt;&lt;/li&gt; </code></pre> <p>But since you want to postback, you should set the <code>DisplayMode</code> of your <code>BulletedList</code> control to <code>LinkButton</code>. When you do that, you'll enable a postback back to your page and your event handler will trap the event. You can then process the click appropriately then. The event argument that's passed in (of type <code>BulletedListEventArgs</code>) will have an <code>Index</code> property, and that will tell you what item in your list was clicked.</p> <p>Here's the updated .aspx code that I used:</p> <pre><code>&lt;asp:BulletedList ID="bullet" runat="server" DisplayMode="LinkButton" onclick="bullet_Click"&gt; &lt;asp:ListItem Text="One" Value="1"&gt;One&lt;/asp:ListItem&gt; &lt;/asp:BulletedList&gt; </code></pre> <p>Everything else is the same except the <code>DisplayMode</code>, which is set to <code>LinkButton</code>. When I use that, then my <code>bullet_Click</code> event handler is fired when I click a list item.</p> <p>I hope this helps!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload