Is there a way I can send my div id to my asp delete button?
div.ID = String.Format("{0}", reader.GetString(0));
div.Attributes.Add("onclick", "return clickTheButton();");
protected void btnDelete_Click(object sender, EventArgs e)
{
//serverside code if confirm was pressed.
using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=root; Password=commando;"))
{
cn.Open();
using (OdbcCommand cmd = new OdbcCommand("DELETE FROM WallPosting WHERE idWallPosting = " + id + ")", cn))
{
cmd.ExecuteNonQuery();
}
}
// //PopulateWallPosts();
}
}
ASP:
<script type="text/javascript">
function confirm_delete()
{
return confirm("Are you sure you want to delete this comment?");
}
function clickTheButton() {
document.getElementById('<%= btn.ClientID %>').click();
}
</script>
<p>
<asp:Button ID="btn" OnClientClick="return confirm_delete();" OnClick="btnDelete_Click" runat="server" Text="delete"/>
I need to find a way I can send the div id to the button delete so I can use my sql syntax, atm I cant see a way of how to send it.