javascript - Document.getElementById('Button').click(); not triggering Code-Behind -
i'm new coding javascript/vb.net , i'm having trouble making button2 onclick event fire.
code-behind click event button1 in page.aspx.vb
protected sub _lnbcomments_click(byval sender object, byval e system.eventargs) //some code needs run before opening modal page dim script 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 correct jsbutton.click() //this should trigger onclick event , open modalpage }
page onload of page.aspx
me._hiddenbtncomments.attributes.add("onclick","showmodal('somepage.aspx','somepage','somestyle')")
the problem javascript code being fired , modal page opened. however, after closing modal page, code-behind click event not triggered. ideas what's wrong 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 button2 in page.aspx.vb
protected sub _hiddenbtncomments_click(byval sender object, byval e system.eventargs) handles _hiddenbtncomments.click //some code needs run after modal page closes. end sub
edit: friend of mine suggested using window.open instead of window.showmodaldialog() , code-behind click event being triggered! however, need use window.showmodaldialog since users expecting,
click()
doesn't fire click event in javascript. use jquery or use dispatchevent
see post: how simulate click javascript?
Comments
Post a Comment