Hi rajeesh,
Refer below sample.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body
{
padding: 10pt !important;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<!-- Bootstrap -->
<script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css'
media="screen" />
<!-- Bootstrap -->
<center>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#MyPopup">
Open Modal</button>
</center>
<!-- Modal Popup -->
<div id="MyPopup" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title">
</h4>
</div>
<div class="modal-body">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
Id :
<asp:TextBox runat="server" ID="txtId" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class="modal-footer">
<asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="Open" CssClass="btn btn-success" />
</div>
</div>
</div>
</div>
<!-- Modal Popup -->
<div id="Div1" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title">
</h4>
</div>
<div class="modal-body">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
Name:
<asp:TextBox runat="server" ID="txtName" />
Country :
<asp:TextBox runat="server" ID="txtCountry" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" />
</Triggers>
</asp:UpdatePanel>
</div>
<div class="modal-footer">
<asp:Button ID="Button1" Text="Submit" runat="server" OnClick="Submit" CssClass="btn btn-success" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data.SqlClient
Imports System.Data
Code
C#
protected void Open(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtId.Text))
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("SELECT Name,Country FROM CustomerTest WHERE CustomerId = @Id", con);
cmd.Parameters.AddWithValue("@Id", txtId.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
txtName.Text = dt.Rows[0]["Name"].ToString();
txtCountry.Text = dt.Rows[0]["Country"].ToString();
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowPopup", "$('#Div1').modal('show')", true);
}
}
protected void Submit(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "HidePopup", "$('#Div1').modal('hide')", true);
}
VB.Net
Protected Sub Open(ByVal sender As Object, ByVal e As EventArgs)
If Not String.IsNullOrEmpty(txtId.Text) Then
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Dim con As SqlConnection = New SqlConnection(constr)
Dim cmd As SqlCommand = New SqlCommand("SELECT Name,Country FROM CustomerTest WHERE CustomerId = @Id", con)
cmd.Parameters.AddWithValue("@Id", txtId.Text)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim dt As DataTable = New DataTable()
da.Fill(dt)
txtName.Text = dt.Rows(0)("Name").ToString()
txtCountry.Text = dt.Rows(0)("Country").ToString()
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "ShowPopup", "$('#Div1').modal('show')", True)
End If
End Sub
Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs)
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "HidePopup", "$('#Div1').modal('hide')", True)
End Sub
Screenshot