Hi chetan,
Please take reference the below code and correct your code.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="container">
<div class="newscon">
<h2>
<b style="font-family: Arial, Helvetica, sans-serif; color: #1ea421">
<asp:Label ID="newsheader" runat="server" Text=""></asp:Label></b></h2>
<br />
<asp:Image runat="server" ID="ImgNews" />
<p runat="server" style="text-align: justify; font-family: 'Poppins'; font-size: 30px;"
id="newscontent">
</p>
</div>
</div>
</div>
</form>
</body>
</html>
Namespaces
C#
using System.Data.SqlClient;
using System.Configuration;
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
string str = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
using (SqlConnection con = new SqlConnection(str))
{
using (SqlCommand cmd = new SqlCommand("SELECT Name, Country FROM Customers", con))
{
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
newsheader.Text = HttpUtility.HtmlDecode(dr["Name"].ToString());
newscontent.InnerText = HttpUtility.HtmlDecode(dr["Country"].ToString());
con.Close();
}
}
}
}
}
Screenshot