c# - No response when call button click in javascript -


good day,

i have aspx contain button id button1, following aspx code :

<div> <asp:linkbutton id="lnkview" commandname="view" runat="server">view</asp:linkbutton> <asp:button id="button1" runat="server" text="ok" onclick="button1_click" /> </div> /* code here */ <script> function test()             {                 document.getelementbyid("<%=button1.clientid %>").click(); alert("hello");     return true;             } </script> 

the following aspx code behind:

//some code here lnkview.attributes.add("onclick", "return test()"); //some code here  protected void button1_click(object sender, eventargs e)     {         scriptmanager.registerstartupscript(this.page, this.gettype(), "javascript", "<script>alert('record added successfully')</script>", false);          } 

as can see, linkview link button have javascript function test() when click on it. can alert "record added successfully" click on button1. however, when click on linkview link button, "record added successfully" didnt alert, alert "hello".

i think missunderstand in programming concept. kindly advise. thanks.

this trigger event in code behind.

try in .aspx page:

//code:

<script type="text/javascript"> function test(parameter) {   __dopostback('button1_click', parameter) } </script> 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -