javascript - Misfiring event for Dynamic control -


in asp.net application, created imagebutton "login" dynamically. added attribute "onclick" "login", during page_load. again adding same attribute "onclick" "login".

code behind:

public partial class calendar : system.web.ui.page {    protected void page_load(object sender, eventargs e)    {       imagebutton login = new imagebutton();       login.attributes.add("onclick", "inclick();");       page.controls.add(0,login);    }     protected void button1_click(object sender, eventargs e)    {       login.attributes.remove("onclick");       login.attributes.add("onclick","outclick();");    } } 

javascript:

<script type="text/javascript">   function inclick()   {      alert("from inclick()");   }   function outclick()   {      alert("from outclick()");   } </script> 

while page_loads onclick event should "inclick()". if, button_clicked onclick event should "outclick()".

for me first attribute firing rightly, once clicked login button. second attribute firing after double clicking "login" button.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -