Hi akhter,
Use Request.Form collection to retrieve the value.
Request.Form collection is used as in some browsers the Text property does not hold the value set from Client Side when the TextBox is set as ReadOnly.
Check below code.
HTML
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<link rel="Stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" />
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script type="text/javascript">
$(function () {
$("[id$=txtbldate]").datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: '/Images/calender.png',
dateFormat: "dd/mm/yy"
});
$("[id$=txtibndate]").datepicker({
showOn: 'button',
buttonImageOnly: true,
buttonImage: '/Images/calender.png',
dateFormat: "dd/mm/yy"
});
$(".js-example-placeholder-single").select2({
placeholder: "Select",
allowClear: true
});
});
</script>
<table>
<tr>
<td>IBN Date :</td>
<td>
<asp:TextBox ID="txtibndate" ReadOnly="true" runat="server" class="form-control"> </asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button Text="Save" runat="server" OnClick="OnSave" />
</td>
</tr>
</table>
Namespaces
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
Code
protected void OnSave(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
using (SqlCommand cmd = new SqlCommand("Sp_Insert_ImpM", con))
{
cmd.Parameters.AddWithValue("@Action", "INSERTM");
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@imp_ibn_date", Request.Form[txtibndate.UniqueID].Trim());
con.Open();
int I_ID = Convert.ToInt32(cmd.ExecuteScalar());
con.Close();
}
}