Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 752483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:47:11+00:00 2026-05-14T14:47:11+00:00

I have a simple user control with this code: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs"

  • 0

I have a simple user control with this code:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Pager.ascx.cs" Inherits="Pager" %>
<table style="width: 100%;">
    <tr>
        <td runat="server" id="PageControls">
            <!-- This button has the problem: -->
            <asp:Button ID="btnPrevPage" runat="server" Text="&larr;" OnClick="btnPrevPage_Click" />
            Page
            <asp:DropDownList runat="server" ID="ddlPage" AutoPostBack="true" OnSelectedIndexChanged="ddlPage_SelectedIndexChanged" />
            of
            <asp:Label ID="lblTotalPages" runat="server" />
            <!-- This button has the problem: -->
            <asp:Button ID="btnNextPage" runat="server" Text="&rarr;" OnClick="btnNextPage_Click" />
        </td>
        <td align="right" runat="server" id="itemsPerPageControls">
            <asp:Literal ID="perPageText1" runat="server" />
            <asp:DropDownList ID="ddlItemsPerPage" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlItemsPerPage_SelectedIndexChanged" />
            <asp:Literal ID="perPageText2" runat="server" />
        </td>
    </tr>
</table>

As you can see, the 2 buttons are wired to click events, which are defined correctly in the code-behind.

Now, here is how I include an instance of the control on my page:

 <uc:Pager ID="Pager1" runat="server" TotalRecords="100" DisplayItemsPerPage="true"
        ItemsPerPageChoices="10,25,50,100" ItemsPerPageFormatString="Sessions/Page: {0}"
        PageSize="25" OnPageChanged="PageChanged" OnPageSizeChanged="PageChanged" />

I noticed though, that the 2 buttons in my user control weren’t causing a post back when clicked. The drop down list does cause postback, though. Here is the rendered HTML:

<table style="width: 100%;">
    <tr>
        <td id="ctl00_MainContent_Pager1_PageControls" align="left">
            <!-- No onclick event! Why? -->
            <input type="submit" name="ctl00$MainContent$Pager1$btnPrevPage" value="←" id="ctl00_MainContent_Pager1_btnPrevPage" />
            Page
            <select name="ctl00$MainContent$Pager1$ddlPage" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$Pager1$ddlPage\',\'\')', 0)"
                id="ctl00_MainContent_Pager1_ddlPage">
                <option value="1">1</option>
                <option selected="selected" value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
            </select>
            of <span id="ctl00_MainContent_Pager1_lblTotalPages">6</span>
            <!-- No onclick event! Why? -->
            <input type="submit" name="ctl00$MainContent$Pager1$btnNextPage" value="→" id="ctl00_MainContent_Pager1_btnNextPage" />
        </td>
        <td id="ctl00_MainContent_Pager1_itemsPerPageControls" align="right">
            Sessions/Page:
            <select name="ctl00$MainContent$Pager1$ddlItemsPerPage" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$Pager1$ddlItemsPerPage\',\'\')', 0)"
                id="ctl00_MainContent_Pager1_ddlItemsPerPage">
                <option value="10">10</option>
                <option selected="selected" value="25">25</option>
                <option value="50">50</option>
                <option value="100">100</option>
            </select>
        </td>
    </tr>
</table>

And, as you can see, there is no onclick attribute being rendered in the button’s input elements. Why not?

EDIT

Ronnie, why are you so dumb??? <input type="submit" /> doesn’t use javascript to post a form!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:47:12+00:00Added an answer on May 14, 2026 at 2:47 pm

    The is no Click even on the buttons because they are input type=submit and so do not require javascript to cause the postback.

    Do you have any updatepanels in your page at all that could be causing the problem?

    Do you have any validators on the page that may be stopping the postback? You might want to set CausesValidation to false if this is the case.

    Have you set break points in the Page_Load of your page and control rather than just in the Click event to check that is working.

    Have you done anything related to disabling ViewState?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 367k
  • Answers 367k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try this (reformatted JSON - next time check your JSON… May 14, 2026 at 4:47 pm
  • Editorial Team
    Editorial Team added an answer Password are hashed and then save to the database, thus… May 14, 2026 at 4:47 pm
  • Editorial Team
    Editorial Team added an answer Your function has no object context, so this references to… May 14, 2026 at 4:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.