I am beginner in ASP.NET and after lot of searching I've decided to ask you guys.

So, I have object created in embedded block in my Page.aspx in following way:

<% Invoice invoice = InvoiceGateway.get(1); %>

Implementation of these is in different files Invoice.cs and InvoiceGateway.cs I am using it to fill webelements right where I need it in this way:

<p class="list-group-item-text"><%= invoice.getCreator().getAddress() %></p>

But now I've started to create buttons and I am trying to call method of this object when I click the button e.g.

<a class="btn btn-danger" runat="server" onServerClick="<% invoice.delete() %>">
     delete
</a>

I know this is not correct, its just for illustration of what I am trying to achieve.

I am not sure how (or even if) I can do that. I know I can define some function in .aspx.cs page and call it onServerClick, or just redirect to Page.aspx?delete={id} and perform something on load.

My question is... Is there a way how to call method of such created object, after I click some hyperlink/button/etc? I've come up with some alternatives, but nothing that would use this already created object and its method.

Related posts

Recent Viewed