Note that there are some explanatory texts on larger screens.

plurals
  1. POMethod being triggered on page load but not via asp button
    primarykey
    data
    text
    <p>I have two asp:Labels, the first of which is replaced with a few buttons and the second with a list of items.</p> <p>I want to click on the buttons to filter the items.</p> <p>The contents of the buttons are added programmatically by replacing the text with html and works fine.</p> <p>asp:</p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;asp:Label id="filters" runat="server" Text="Filters here"/&gt; &lt;asp:Label id="itemList" runat="server" Text="List of items here"/&gt; &lt;/form&gt; </code></pre> <p>resultant html of filters label:</p> <pre><code>&lt;input type="submit" onclientclick="Load_Items(0)" runat="server" value="First"/&gt; &lt;input type="submit" onclientclick="Load_Items(1)" runat="server" value="Second"/&gt; &lt;input type="submit" onclientclick="Load_Items(2)" runat="server" value="Third"/&gt; </code></pre> <p>relevant c#:</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Load_Items(0); } } public void Load_Items(int filterType) { //code to load items (pseudo below) for each row in list if filterType = itemType build string replace second label with string } </code></pre> <p>On page load everything happens just as I want it to with the contents being filtered by the first item (hence <code>Load_Items(0)</code>), and if I manually change the 0 to another number in Page_Load, it filters by the other types, but if I click the buttons which are programmatically added, nothing happens other than what looks like the page refreshing.</p> <p>I know the post back check is working by adding a text replacement before and inside it.</p> <p>I've also added an asp:button to make sure it's not something to do with the way the buttons are added as below (with some extra things recommended from searches):</p> <pre><code>&lt;asp:Button runat="server" CausesValidation="False" onclientclick="Load_Items(2); return false;" text="Submit" /&gt; </code></pre> <p>So what could be the issue?</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.
 

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