Set focus on TextBox inside Bootstrap Modal Popup inside ASP.Net UpdatePanel using jQuery

Last Reply 8 months ago By pandeyism

Posted 8 months ago

Refrence to your below link

Open (Show) Bootstrap Modal Popup Window using jQuery

i want to open this dialog inside update panel and add textbox in dialog. 

when dialog will be open autofocus on textbox 


Posted 8 months ago

Hi arehman,

Refer below sample.


<html xmlns="">
<head runat="server">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <link rel="stylesheet" href="" />
    <script type="text/javascript">
        function ShowPopup() {
            $('#myModal').on('', function () {
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server">
    <asp:UpdatePanel runat="server">
                <br />
                <asp:Button Text="Show Popup" runat="server" ID="btnShowPopup" class="btn btn-info btn-lg"
                    OnClientClick="ShowPopup()" OnClick="btnShowPopup_Click" />
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">
                                    Modal title</h4>
                            <div class="modal-body">
                                <input type="textusername" id="txtUserName" class="form-control" style="width: 300px"
                                    name="name" value="" />
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">
                                <button type="button" class="btn btn-primary">
                                    Save changes</button>



protected void btnShowPopup_Click(object sender, EventArgs e)
    ScriptManager.RegisterStartupScript((sender as Control), this.GetType(), "Popup", "ShowPopup();", true);


Protected Sub btnShowPopup_Click(sender As Object, e As System.EventArgs)
    ScriptManager.RegisterStartupScript(CType(sender, Control), Me.GetType(), "Popup", "ShowPopup();", True)
End Sub