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

  • Home
  • SEARCH
  • 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 6768891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:07:41+00:00 2026-05-26T15:07:41+00:00

Within an asp.net webform I have some jquery that controls the positioning of elements

  • 0

Within an asp.net webform I have some jquery that controls the positioning of elements on the page. Since this is a webform and some of these controls talk to the server to get jquery to work I have the controls nested in an AJAX UpdatePanel to prevent postbacks from resetting my controls.

aspx:

<asp:UpdatePanel ID="searchupdatePanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <div id="searchholder" >
            <div id="searchoptions">
                <a href="#" id="btnClose">Close</a> <a href="#" id="btnAdvanceSearch">Advanced Search</a>
                <br />
                <a href="#" id="btnFilters">Filters</a>
            </div>
            <div id="search" class="searchcontainer">
                <asp:TextBox ID="tbsearchterm" CssClass="watermark" runat="server" OnTextChanged="tbsearchterm_TextChanged" />
                <div class="buttons">
                    <asp:LinkButton runat="server" Text="Search" class="button search-big" ID="btnSearch" OnClick="btnSearch_Click" />
                    <asp:LinkButton runat="server" Text="Fx" class="button left big" ID="btnOperators" />
                    <asp:LinkButton runat="server" Text="Save" class="button right big" ID="btnSave" />
                </div>
            </div>
            <div id="divAdvSearch">
            </div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

<div id="divBody">
    <asp:UpdatePanel runat="server" UpdateMode="Always">
        <ContentTemplate>
            <div id="divSearchResults" visible="true" runat="server">
                <uc:SearchResultsControl ID="SearchResultsControl" runat="server"></uc:SearchResultsControl>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

When the search button is clicked I modify the css class for the search control to reposition my search div layer which is the update panel “searchudpatepanel”

searchcontrol.js

$(function () {
    $("#searchupdatePanel").addClass("searchmenubar");
    $("#btnClose").hide();
});

$(function () {
    $("#btnSearch").click(function () {
        $(".searchmenubar").animate({ "margin-top": "5px" }, "fast");
        $("#btnAdvanceSearch").show();
        $("#btnFilters").show();
        $("#btnClose").hide();
        $("#divAdvSearch").hide();
        alert("search");
    });
});

The button click also calls serverside code to retrieve and populate the results within a user control called SearchResultsControl ( second update panel)

Where I am confused is when the searchResult Control is loaded with the results all references to the jquery classes are lost. As a result every div element that is hidden or button click that is called ceases to work. Working through this in debug I can see when the user control is called the Page_Load for the default.aspx file is invoked as second time. I assume this partial load is dropping reference to the js files I just don’t know how to correct this.

I tried a test within the page load using IsStartupScriptRegistered to see if the js was getting called

string csname = "PopupScript";
Type cstype = this.GetType();

ClientScriptManager cs = Page.ClientScript;

if (!cs.IsStartupScriptRegistered(cstype, csname))
{
    StringBuilder cstext1 = new StringBuilder();
    cstext1.Append("<script type=text/javascript> alert('Hello World!') </");
    cstext1.Append("script>");
    cs.RegisterStartupScript(cstype, csname, cstext1.ToString());
}

Here on the initialization of the page I would see the pop up occur however when the UserControl was loaded I would pass through this a second time in the page load but the alert never displayed( I assume this is due to a partial load so the browser thinks the script is already registered).

The only other thing I can think of is I am overriding the rendering of the UserControl being loaded as it loads a custom result set.

protected override void Render(HtmlTextWriter htw)
{
    if (IsPostBack)
    {
        QueryResponse qr = iu.GetSearchResults(SearchTerm);
        int num = qr.TotalMatchesReturned;

        SearchData sd = new SearchData();
        htw.Write("<table style='width: 100%; height:100%'><tr ><td style='width: 50%'>");
        htw.Write("<div id='divResultDetail' runat=server >");
        htw.Write("<script type='text/javascript' src='../js/paging.js'></script><div id='pageNavPosition'></div><table id='results'>");

        for (int i = 0; i < num; i++)
        {
            ...edited for brevity.

Any suggestions or guidance as to why I am losing reference to the jquery functions? I am not using master pages so I haven’t used the ASP ScriptManager.

This all worked fine prior to using UpdatePanels. I define “fine” as: the postback was reloading/registering the js files each time, so they were being reset (which was okay). However, now with some other changes needed I need to look at leveraging UpdatePanels.

Thanks for any suggestions or ideas.

  • 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-26T15:07:42+00:00Added an answer on May 26, 2026 at 3:07 pm

    You can use the live or delegate jQuery methods to get your handlers to be bound to any elements added to the page.

    Alternatively, if you need some setup to always happen after every partial postback in addition to original page load, you can put it in a pageLoad method instead of document.ready. ASP.NET calls this on page load, and after every partial postback.

    function pageLoad()
    {
        // Setup code here
    }
    

    Check this article for more:
    http://encosia.com/document-ready-and-pageload-are-not-the-same/

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

Sidebar

Related Questions

I have used JQuery within my asp.net page. JQuery is working fine. I could
The situation I have an ASP.NET Webform that contains some status information about a
within an asp.net webform project I have a session variable that I am populating
I have an ASP.NET site that uses JQuery and ASP.NET UpdatePanel and ScriptManager. On
I have an ASP.Net UpdatePanel that updates on a timer. Within the UpdatePanel and
Within an ASP.NET AJAX UpdatePanel on my page I have a submit button which
I have an asp.net backend that creates Hierarchical Data based on IHierarchicalEnumerable. This was
-- Running within ASP.NET MVC alongside jQuery -- I'm using jQuery to render a
I am using the jQuery nyroModal plugin within ASP.Net. I love nyroModal, and overall
I have a form within an ASP.NET MVC application and I'm trying to submit

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.