C# onserver单击和onclick不起作用
从我的代码隐藏im加载html列表中的数据(表): ASPC# onserver单击和onclick不起作用,c#,html,asp.net,C#,Html,Asp.net,从我的代码隐藏im加载html列表中的数据(表): ASP 名义 拉松社会 特莱福诺酒店 电子邮件 "; tableData.Text+=“它不是那样工作的。如果您使用runat=“server”将控件放置在aspx表单上,则该控件将在服务器上处理,并使用适当的javascript函数(如果您指定类似于OnClick的事件)将输出html返回给客户机,以将表单发回。如果像您这样生成字符串并将其分配给文字,则它将“按原样”呈现,因为服务器端处理已经发生,所以runat=“server”在这里没有
名义
拉松社会
特莱福诺酒店
电子邮件
";
tableData.Text+=“它不是那样工作的。如果您使用runat=“server”将控件放置在aspx表单上,则该控件将在服务器上处理,并使用适当的javascript函数(如果您指定类似于OnClick的事件)将输出html返回给客户机,以将表单发回。如果像您这样生成字符串并将其分配给文字,则它将“按原样”呈现,因为服务器端处理已经发生,所以runat=“server”在这里没有任何意义-它只是一个字符串
要实现您想要的,我建议使用带有链接按钮控件的中继器控件。网络上有很多例子/教程如何做。我认为你的问题可以用LinkButton
或Hyperlink
而不是锚定标签来解决。这是正确的。。。如果您查看源代码,您将注意到源代码中的runat=“server”。如果它像在ASPX页面中一样正确使用,而不是呈现数据,那么runat=“server”将不会呈现在您的视图源中
<table id="tblClientes" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Nombre</th>
<th>Razón Social</th>
<th>Teléfono</th>
<th>Email</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<asp:Literal runat="server" ID="tableData"></asp:Literal>
</tbody>
tableData.Text += "<tr>";
tableData.Text += "<td>" + cliente.Nombre + "</td>";
tableData.Text += "<td>" + cliente.RazonSocial + "</td>";
tableData.Text += "<td>" + cliente.Telefono + "</td>";
tableData.Text += "<td>" + cliente.Email + "</td>";
tableData.Text += "<td><a href='#' runat='server' onserverclick='btnCargarDatosCliente_Click' data-toggle='modal' data-target='#ventanaEmergente' id='btnCargarDatosCliente_" + cliente.Id.ToString() + "'>Editar</a></td>";
tableData.Text += "<td><input type='button' data-toggle='modal' data-target='#ventanaAdvertencia' id='btnEliminarCliente_" + cliente.Id.ToString() + " value='Borrar' runat='server'/>Elimiar</td>";
tableData.Text += "</tr>";