<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Default.aspx/Spotlight",
data: '{}',
dataType: "json",
success: function (data) {
var myobject = JSON.stringify(data.d);
$($.parseJSON(myobject)).each(function (index, el) {
$('.titleofpost').text(el.post_title).replace('/+/g', ' ');
$('.titleofpost').attr('href', el.post_title);
$('.appendspotlight').text(el.post_description);
// document.write(el.post_title,el.post_date, el.post_credit, el.post_description, el.post_views);
});
},
error: OnError
});
});
}
</script>
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public static List<Posts> Spotlight()
{
string query = "select TOP 1 post_date,post_tags,post_title,post_credit,post_id,post_description,post_views,post_image,post_know from posts where post_highlited=1";
SqlCommand cmd = new SqlCommand(query);
DataSet ds = GetData(cmd);
DataTable dt = ds.Tables[0];
foreach (DataRow item in ds.Tables[0].Rows)
{
Posts post = new Posts();
post.post_title = HttpUtility.UrlEncode(item["post_title"].ToString());
post.post_credit = item["post_credit"].ToString();
post.post_date = String.Format("{0:ddd, MMM d, yyyy}", item["post_date"]);
post.post_description = item["post_description"].ToString();
post.post_know = item["post_know"].ToString();
post.post_views = Convert.ToInt16(item["post_views"]);
productt.Add(post);
}
return productt;
}
I am getting json value for post_title in this format
since i am using httputility.urlencode
I want to remove + and make it look like