So what I have is a form and part of this form will be used to create a jquery dialog. From that dialog is a button, created from asp server control, that I will click. The server control has a function in the code behind that will be called when clicked. The problem I have is that the function in the code behind is not being called. Is there something fundamental that I am missing? Here is what the aspx page look like, stripped down to the bare minimum
<head>
<script>
function PreviewForm() {
$("#emailPreview").attr("style", "");
$("#emailPreview").dialog({
title: "Preview",
width: "890px",
modal: true
});
}
</script>
</head>
<body>
<form id="EmailSend" method="post" runat="server">
<table>
<tr>
<td style="text-align:right">
<input type="button" onclick="PreviewForm();" value="Preview" />
</td>
</tr>
</table>
<div id="emailPreview" align="center" style="display:none">
<fieldset>
<table>
<tr class="Row">
<td class="required">Subject:</td>
<td><asp:Label ID="lblSubj" Runat="server" /></td>
</tr>
<tr>
<td class="field" colspan="2" style="text-align:center">
<input id="btnBack" class="button" type="button" onclick="closeDialog(false);" value="Close" />
<asp:Button ID="Send" class="button" Runat="server" Text="Send"/>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
and the function in the code behind
Private Sub CmdSendClick(ByVal sender As System.Object, ByVal e As EventArgs) Handles Send.Click
lblSubj.Text.Trim(), pBody)
End Sub
When I try debugging the code not thing happens, the break point was not being hit. If I were to make the button visible and click from outside the dialog box that I created then it would work fine.
EDIT
I also tried it where I hide the button outside of the dialog and then click the button once the dialog is closed. so the closeDialog function will look like this with a new input button
function closeDialog(send) {
console.log(send);
if (send) {
$("#emailPreview").dialog("close");
GetFormControl('<%=Send.ClientID%>').click();
console.log(send + " TRUE");
} else {
$("#emailPreview").dialog("close");
console.log(send + " false");
}
}
<div id="emailPreview" align="center" style="display:none">
<fieldset>
<table>
<tr class="Row">
<td class="required">Subject:</td>
<td><asp:Label ID="lblSubj" Runat="server" /></td>
</tr>
<tr>
<td class="field" colspan="2" style="text-align:center">
<input id="btnBack" class="button" type="button" onclick="closeDialog(false);" value="Close" />
<input type="button" onclick="closeDialog(true);" value="Send Email" />
</td>
</tr>
</table>
</fieldset>
</div>
<asp:Button ID="Send" class="button" Runat="server" Text="Send"/>
</form>
I actually get the error
SCRIPT5007: Unable to get property 'click' of undefined or null reference
EDIT 2
As requested, also I do know about using eval, the no no of it, but I am maintaining some else's code here. So let's pretend it is ok
function GetFormControl(fControlName) {
var oControl = eval('document.EmailSend.' + fControlName);
if (oControl == null)
oControl = GetPageElement(fControlName);
return oControl;
}