c# - ASP.NET button works with alerts but not triggering page_load or code behind method -


i have asp.net button in update panel,

if put alert('hello'), works otherwise if put code behind method, doesn't work, ideas ?

<asp:button id="button1" onclick="alert('why');" text="submit" runat="server" cssclass="leftbutton" />       // works !!!         <asp:button id="button1" onclick="codebehind_click" text="submit" runat="server" cssclass="leftbutton" /> // doesn't work 

i tried adding triggers panel , no change.

update

onclient or onclientclick, no of them works :(

useless update

protected void codebehind_click(object sender, eventargs e)         {  // not triggering page_load neither method } 

you need onclick instead of onclientclick binding server side event. can read more on here server side click event.

in code behind should have handler.

void codebehind_click(object sender, eventargs e) {  } 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -