protected void sendno_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["str"].ToString());
//Open the database connection
con.Open();
SqlCommand cmd = new SqlCommand("Insert into ContactNumber(Number,Ip,Country,City,Region) values(@Number,@Ip,@Country,@City,@Region)", con);
//Passing parameters to query
cmd.Parameters.AddWithValue("@Number", mbtxt.Text.Trim().ToString());
cmd.Parameters.AddWithValue("@Ip", txtip.Text.ToString());
cmd.Parameters.AddWithValue("@Country", txtCountry.Text.ToString());
cmd.Parameters.AddWithValue("@City", txtStreet.Text.ToString());
cmd.Parameters.AddWithValue("@Region", txtCity.Text.ToString());
cmd.ExecuteNonQuery();
//Close dbconnection
con.Close();
Label6.Text = "Received";
}
}
<script type="text/javascript">
var strip, strcountry, strcity, strregion
function GetUserInfo(data) {
strip = data.host; strcountry = data.countryName; strcity = data.city;
strregion = data.region;
}
$(function () {
BindUserInfo();
})
function BindUserInfo() {
document.getElementById('<%= txtip.ClientID %>').innerHTML = strip;
document.getElementById('<%= txtCountry.ClientID %>').innerHTML = strcountry;
document.getElementById('<%= txtCity.ClientID %>').innerHTML = strcity;
document.getElementById('<%= txtStreet.ClientID %>').innerHTML = strregion;
}
</script>
<div >
<asp:Label ID="txtStreet" runat="server"></asp:Label>
<asp:Label ID="txtCountry" runat="server"></asp:Label>
<asp:Label ID="txtip" runat="server"></asp:Label>
<asp:Label ID="txtCity" runat="server"></asp:Label>
</div>
<br />
<asp:TextBox ID="mbtxt" runat="server" Width="256" CssClass="phone"></asp:TextBox>
<%-- <Controls:Captcha ID="captcha" runat="server" CalcMode="1" />--%>
<br />
<asp:Button ID="sendno" runat="server" Text="Send" OnClick="sendno_Click" />
Sir i am able to display location on label on page but when i insert it with the mbtxt in database i am getting only number inserted lalbel values are not inserted