Reputation: 1571
I'm trying to call the vb method by clicking on the div but i get that the method is not defined.
My Code:
<div id="Div1" class="btn btn-primary pull-right" runat="server" onclick="prueba2()" >
</div>
<script type="text/VB" runat="server">
Sub prueba2()
MsgBox("seee")
End Sub
</script>
Debug: Uncaught ReferenceError: prueba2 is not defined
Thanks in advance!
Upvotes: 0
Views: 1114
Reputation: 15797
In this case, the onclick
is for javascript:
<div id="Div1" class="btn btn-primary pull-right" runat="server" onclick="prueba2()" ></div>
<script type="text/javascript">
function prueba2() {
//do something
}
</script>
Note, for ASP.NET controls, this is not the same. They will have OnClick
for the code behind function and OnClientClick
for the client-side javascript function:
<asp:Button ID="_someButton" OnClick="VBFunction" Text="Some Text" OnClientClick="prueba2()" runat="server" />
Upvotes: 3
Reputation: 12748
You'll have to change your onclick to a javascript that will submit the form using a button.
__doPostBack('btnTemp', '');
Where btnTemp is a button.
You can find a great example here: Adding OnClick event to ASP.NET control
Upvotes: 0