I'm trying to build a table in code-behind. What I have looks like this:
Content += "<tr>";
Content += "<td>" + dt.Rows[i]["Provision"].ToString() + "</td>";
Content += "<td>" + dt.Rows[i]["MarkForReview"].ToString() + "</td>";
Content += "<td>" + dt.Rows[i]["IssueType"].ToString() + "</td>";
Content += "<td>" + dt.Rows[i]["Resolution"].ToString() + "</td>";
Content += "<td>" + dt.Rows[i]["Feedback"].ToString() + "</td>";
Content += "<td><input type=\"button\" ID=\"btnEdit\" runat=\"server\" OnClick=\"btnEdit_OnClick\" Text=\"Edit\" /></td>";
Content += "</tr>";
The problem is in how I'm rendering the Edit button. When the code runs, what's rendered for the button looks like this:
<td><input type="button" ID="btnEdit" runat="server" OnClick="btnEdit_OnClick" Text="Edit" /></td>
it keeps giving me a "JavaScript runtime error" that btnEdit_OnClick doesn't exist, but I have this in my code-behind:
protected void btnEdit_OnClick(object sender, EventArgs e)
{
MdlCommentsExtender.Enabled = true;
MdlCommentsExtender.Show();
ScriptManager.GetCurrent(this).SetFocus(this.txtCommentBox);
}
Also, the button renders with no text. It's just a small gray button.
Any ideas what I'm doing wrong?
OnLoadmethod or something close to it, you need to subscribe to the event, otherwise the publisher is oblivious. Not sure about everything in your code, but using what is available right now,Content.OnClick += btnEdit_OnClickor something similar to that.