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 8330163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:02:15+00:00 2026-06-09T02:02:15+00:00

<%@ Control Language=C# AutoEventWireup=true CodeBehind=ChatUserControl.ascx.cs Inherits=MetamorphismApp.ChatUserControl %> <asp:Timer ID=timer1 runat=server OnTick=timer1_Tick Interval=5000> </asp:Timer> <div

  • 0
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ChatUserControl.ascx.cs"
    Inherits="MetamorphismApp.ChatUserControl" %>
<asp:Timer ID="timer1" runat="server" OnTick="timer1_Tick" Interval="5000">
</asp:Timer>
<div id="divChatWindow" class="clChatWindow">
    <div>
        <asp:Label runat="server" Text='<%# Eval("username") %>' class="divHeader" ID="lblChatFriend"></asp:Label>
        <asp:Image ID="imgFriend" runat="server" CssClass="classFriendImage"/>
        <asp:LinkButton ID="lbClose" runat="server" CommandName="Close" CssClass="lbClose"
            OnClick="lbClose_Click">Close</asp:LinkButton></div>
    <div class="chatText" id="idChatText" runat="server">
        <asp:UpdatePanel ID="UpdatePanel" runat="server">
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick" />
                <asp:AsyncPostBackTrigger ControlID="btnSendChat" EventName="Click" />
            </Triggers>
            <ContentTemplate>
                <asp:Repeater runat="server" ID="rpChatMessages">
                    <ItemTemplate>
                        <asp:Image ID="imageForFriend" runat="server" CssClass="clFriendsImage" ImageUrl='<%# "HttpImageHandler.jpg?username=" +  DataBinder.Eval(Container.DataItem,"fromusername").ToString() %>' />
                        <asp:Label ID="chatMessage" runat="server" Text='<%# Eval("Message") %>'></asp:Label>
                        <br>
                    </ItemTemplate>
                </asp:Repeater>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <asp:TextBox ID="txtChatMessage" runat="server" Width="142px" CssClass="clChatMessage"
        TextMode="MultiLine"></asp:TextBox>
    <asp:LinkButton ID="btnSendChat" runat="server" CommandName="Insert" CommandArgument='<%# Eval("username") %>'
        OnClick="btnSendChat_Click">Send</asp:LinkButton>
</div>





protected void btnSendChat_Click(object sender, EventArgs e)
    {
        TextBox txt = this.FindControl("txtChatMessage") as TextBox;
        string username = lblChatFriend.Text;            
        ucc.InsertMessage(Session["username"].ToString(), username, txt.Text);

        string javaScript = "<script type='text/javascript'>\n" + "CallScroller();\n" + "</script>";
        ScriptManager.RegisterStartupScript(this, typeof(ChatUserControl), "startUpScript", javaScript, false);
    }

btnSendChat function is in a user control code-behind file. CallScroller function doesn’t get called.

  • 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-06-09T02:02:16+00:00Added an answer on June 9, 2026 at 2:02 am

    That’s because RegisterStartupScript is called when your DOM is loaded, the equivalent with jQuery to:

    $(function () { ... });
    

    Since you are capturing the events from your button inside the UpdatePanel using triggers, you are effectively partial rendering your view that’s why the script registered with RegisterStartupScript will never run in this situation

    Alternatives:

    React to the Sys.load event

    This event is raised every time a page is partial rendered.

    Handle the event as follows:

        <asp:ScriptManager runat="server" ID="sm">
    
        </asp:ScriptManager>
        <script type="text/javascript">
            function callScroller() {
                alert("call scroller called");
            }
            Sys.Application.add_load(function () {
                if ($get("hidden").getAttribute("value") == "1") {
                    callScroller();
                }
            });
        </script>
    

    Add a HiddenField inside your UpdatePanel.ContentTemplate to use it as a flag to indicate when to call the JavaScript function, without it, your function would get called on every post

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:HiddenField  runat="server" ID="hidden" Value="0" />
            ....
    

    Finally in the code behind turn on the flag in the event that best fits your needs:

        protected void btnSendChat_Click(object sender, EventArgs e)
        {
            this.hidden.Value = "1";
        }
    

    That’s it

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

Sidebar

Related Questions

I have a simple asp.net user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=QueryDefinitionItem.ascx.cs Inherits=xxx.UserControls.QueryDefinitionItem %>
I have a user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=Autocomplite.ascx.cs Inherits=Application.Controls.Autocomplite %> <script type=text/javascript
I have this user control: <%@ Control Language=C# AutoEventWireup=true CodeBehind=cite.ascx.cs Inherits=cite %> with behind
I have an ascx control; <%@ Control Language=C# AutoEventWireup=true CodeBehind=LanguageSelect.ascx.cs Inherits=MyNamespace.LanguageSelect %> with code
I created ASP.NET user control with javascript function : <%@ Control Language=C# AutoEventWireup=true CodeBehind=TestControl.ascx.cs
I have a CompositeDataBoundControl defined as below: <%@ Control Language=C# AutoEventWireup=true CodeBehind=ReportSection.ascx.cs Inherits=WebReports.ReportSection %>
I have an ASP.Net UserControl that looks like this: <%@ Control Language=C# AutoEventWireup=true CodeBehind=WebUserControl1.ascx.cs
If I have a UserControl like this: <%@ Control Language=C# AutoEventWireup=true CodeBehind=Foo.ascx.cs Inherits=Foo %>
Currently my code resembles this: <%@ Control Language=C# AutoEventWireup=true CodeBehind=CustomPanel.ascx.cs CodeFile=CustomPanel.ascx.cs CodeFileBaseClass=System.Web.UI.WebControls.Panel Inherits=MyProject.CustomPanel %>
this my code in my user control's designer file <%@ Control Language=C# AutoEventWireup=true CodeBehind=ucImageList.ascx.cs

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.