Good evening, I need to reference a PlaceHolder
Asp.Net
component in a static method in code-behind
C#
, this method is called via AJAX
by front-end
see code:
Call the method by the front end Form aspx:
<script type="text/javascript">
function CallCsharpFunction(andamento_id) {
try {
$.ajax({
type: "POST",
url: 'Processo.aspx/AtuarNoProcesso',
data: "{'AndamentoID':'" + andamento_id + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: location.reload(true),
error: function (msg) {
alert(msg.d);
}
});
} catch (err) { }
}
</script>
The Method in Code-Behind C #:
[System.Web.Services.WebMethod]
public static string AtuarNoProcesso(int AndamentoID)
{
PlaceHolder1.Controls.Add(new Literal
{
Text = Andamento.Make_Table_Html(Convert.ToInt32(AndamentoID)) });
}
}
But you get the message "An object reference is required for the non-static field, method, or property"
in the PlaceHolder1
component.
How do I see the PlaceHolder1 component?