Hi taruni,
Check this example. Now please take its reference and correct your code.
HTML
<asp:Button runat="server" ID="btnsupportform" Text="Go Support" OnClick="btnsupportform_Click"
Style="color: #ffffff; font-size: 14px; margin-left: 20px; cursor: pointer; padding: 8px; background-color: #f39c12; border-radius: 8px;" />
<div class="form-group">
<label for="inputName" class="col-sm-3 control-label">Area Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="area_name" placeholder="Area Name" runat="server" />
</div>
</div>
<div class="form-group">
<label for="inputName" class="col-sm-3 control-label">City Name</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="city_name" placeholder="City Name" runat="server" />
</div>
</div>
<div class="form-group">
<label for="inputName" class="col-sm-3 control-label">Pincode</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="pincode" placeholder="Pincode" runat="server" />
</div>
</div>
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="progress.gif" alt="" />
</div>
<style type="text/css">
.modalPopup {
position: fixed;
top: 0;
left: 0;
background-color: transparent;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading {
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
function PopulateTextBox(area, city, pin) {
$('#area_name').val('');
$('#city_name').val('');
$('#pincode').val('');
ShowProgress();
setTimeout(function () {
$('#area_name').val(area);
setTimeout(function () {
$('#city_name').val(city);
setTimeout(function () {
$('#pincode').val(pin);
$(".modalPopup").hide();
$(".loading").hide();
}, 2000);
}, 2000);
}, 2000);
}
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modalPopup");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
loading.css({ top: top, left: left });
}, 200);
}
</script>
Code
C#
protected void btnsupportform_Click(object sender, EventArgs e)
{
bind();
}
public void bind()
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.AddRange(new System.Data.DataColumn[3]
{
new System.Data.DataColumn("area_name"),
new System.Data.DataColumn("city_name"),
new System.Data.DataColumn("pincode")
});
dt.Rows.Add("Malad", "Mumbai", "400097");
if (dt.Rows.Count > 0)
{
string value1 = dt.Rows[0]["area_name"].ToString();
string value2 = dt.Rows[0]["city_name"].ToString();
string value3 = dt.Rows[0]["pincode"].ToString();
string script = "window.onload = function() { PopulateTextBox('" + value1 + "','" + value2 + "','" + value3 + "'); };";
ClientScript.RegisterClientScriptBlock(this.GetType(), "", script, true);
}
}
VB.Net
Protected Sub btnsupportform_Click(ByVal sender As Object, ByVal e As EventArgs)
bind()
End Sub
Public Sub bind()
Dim dt As Data.DataTable = New Data.DataTable()
dt.Columns.AddRange(New Data.DataColumn(2) {
New Data.DataColumn("area_name"),
New Data.DataColumn("city_name"),
New Data.DataColumn("pincode")})
dt.Rows.Add("Malad", "Mumbai", "400097")
If dt.Rows.Count > 0 Then
Dim value1 As String = dt.Rows(0)("area_name").ToString()
Dim value2 As String = dt.Rows(0)("city_name").ToString()
Dim value3 As String = dt.Rows(0)("pincode").ToString()
Dim script As String = "window.onload = function() { PopulateTextBox('" & value1 & "','" & value2 & "','" & value3 & "'); };"
ClientScript.RegisterClientScriptBlock(Me.GetType(), "", script, True)
End If
End Sub
Screenshot