javascript - asp.net button - JS click does not work -
i trying phone call js c# function. can not utilize ajax. have tried create asp.net button when clicked calls c# function , phone call click function js:
on html:
<asp:button runat="server" id="uploadbutton" onclick="upload_click" />
js:
alert("before click"); document.getelementbyid("uploadbutton").click(); alert("after click");
asp.net:
protected void upload_click(object sender, eventargs e) { //code }
the problem click event js not working. have tried write after first line of js code alert see if code rich line can see "after click"
.
i have seen answer: button's .click() command not working in chrome did not quite this.
you should set clientidmode
static
<asp:button runat="server" id="uploadbutton" clientidmode="static" onclick="upload_click" />
otherwise, have randomized id, generated asp.net, setting clientidmode static, you're saying asp.net not meddle ids , maintain them intact.
other alternative utilize clientid
property have value of automatically generated id like
document.getelementbyid('<%= uploadbutton.clientid %>').click();
javascript c# html asp.net click
No comments:
Post a Comment