c# - how to call server side function from javascript -
i looking set sorting on asp repeater. see repeater code:
<asp:repeater runat="server" id="rptclientdetails"> <headertemplate> <table id="example" class="dynamictable table table-striped table-bordered table-primary"> <thead> <tr> <th> <a href="#" onclick="clientsort('clientid')">client id</a> </th> <th> <a href="#" onclick="clientsort('name')">name</a> </th> <th> <a href="#" onclick="clientsort('totalbalancedue')">total balance due</a> </th> </tr> </thead> <tbody> </headertemplate> <itemtemplate> here, calling javascript function. see javascript function code:
function clientsort(sortexpress) { <%= sorting(sortexpress) %> } from here want call .net server side function.
public void sorting(string sortexpression) { string s = sortexpression; } so, have idea how can call it? or directly repeater can call server side function..thanks
directly can call server side code repeater control, use linkbutton instead of href.
<asp:repeater runat="server" id="rptclientdetails"> <headertemplate> <table id="example" class="dynamictable table table-striped table-bordered table-primary"> <thead> <tr> <th> <%--<a href="#" onclick="clientsort('clientid')">client id</a>--%> <asp:linkbutton id="lbtn" text="client id" forecolor="blue" oncommand="lbtnsorting_click" commandargument="clientid" runat="server"></asp:linkbutton> </th> <th> <asp:linkbutton id="linkbutton1" text="name" forecolor="blue" oncommand="lbtnsorting_click" commandargument="name" runat="server"></asp:linkbutton> <%--<a href="#" onclick="clientsort('name')">name</a>--%> </th> <th> <asp:linkbutton id="linkbutton2" text="total balance due" forecolor="blue" oncommand="lbtnsorting_click" commandargument="totalbalancedue" runat="server"></asp:linkbutton> <%--<a href="#" onclick="clientsort('totalbalancedue')">total balance due</a>--%> </th> </tr> </thead> <tbody> </headertemplate> </asp:repeater> and code behind :
protected void lbtnsorting_click(object sender, commandeventargs e) { string s = e.commandargument.tostring(); }
Comments
Post a Comment