I'm new to coding javascript/VB.NET and I'm having trouble making my Button2 onClick event fire.
Code-Behind Click Event for Button1 in Page.aspx.vb
Protected Sub _lnbComments_Click(ByVal sender As Object, ByVal e As System.EventArgs)
//Some Code that needs to run before opening Modal Page
Dim Script As String = "JavaScriptCode();"
ScriptManager.RegisterStartupScript(Me.upnToolBar, Me.upnToolBar.GetType(), "CommentsClick", Script, True)
End Sub
JS File
function ShowModal(page,name,style){
var r = window.showModalDialog(page,window,style);
}
function JavaScriptCode(){
var jsButton = document.getElementById('ct100_SiteContent__hiddenBtnComments'); //I made sure ClientID is correct
jsButton.click() //This should trigger onClick event and OPEN modalPage
}
Page OnLoad of Page.aspx
Me._hiddenBtnComments.Attributes.Add("onclick","ShowModal('SomePage.aspx','SomePage','somestyle')")
The Problem is only the Javascript code is being fired and Modal Page is opened. However, after closing Modal Page, the code-behind click Event is NOT triggered. Any Ideas what's wrong with the code?
Page.aspx Button 2 Mark-up
<asp:Button id="_hiddenBtnComments" runat="server" style="display:none" onclick="_hiddenBtnComments_click"></asp:Button>
Code-Behind Click Event for Button2 in Page.aspx.vb
Protected Sub _hiddenBtnComments_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles _hiddenBtnComments.Click
//Some Code that needs to run AFTER Modal Page closes.
End Sub
EDIT: A friend of mine suggested using window.open instead of window.showmodaldialog() and the code-behind click event is being triggered! However, I need to use window.showmodaldialog since it will be what the users will be expecting,