Reputation: 11
//Controller
public Label CallbackPanelPartial()
{
Label rb = new Label();`
rb.ID = "dd";
rb.Text = "aaa";
return rb;
}
jQuery function to bind label as html content to view
function LoadFormGen(s,e)
{
$.ajax({
type: "POST",
url: '@Url.Action("CallbackPanelPartial", "LoadForm")',
beforeSend: function () {
lpTimeslot.Show();
},
success: function (response) {
$("#genForm").html(response);
pcTimeslotHed.SetHeaderText('Load - [New]');
pcTimeslotHed.Show();
lpTimeslot.Hide();
}
});
}
I'm getting a result as System.Web.UI.WebControl.Label. What I want is to get the html content returned label.
Upvotes: 0
Views: 379
Reputation: 541
Label class will always return an Object not HTML
If you want to get HTML then
First Create an ActionResult which will return a Partial View with Label class Model. assign value accordingly
public ActionResult CallbackPanelPartial()
{
Label rb = new Label();`
rb.ID = "dd";
rb.Text = "aaa";
return PartialView(rb );
}
Create a Partial View with name CallbackPanelPartial.cshtml
which will accept System.Web.UI.WebControl.Label type model
@model System.Web.UI.WebControl.Label
@{
}
<Label id = "@Model.ID">@Model.Text</Label>
Else code will remain same
Upvotes: 1