简体   繁体   中英

Dynamic anchor tag onclick is not calling server function

I am trying to create anchor tags whose onClick fire a server side function. But this is not working. Also I want to pass some parameters whose value takes from db.

html.Append("<tr id='" + evidenceID + "'>" +
                                        "<td><a id='" + titleId + "' href='#' runat='server' OnClick='StreamVideoCall('" + parameters + "')'>" + myDeserializedObjList[item].attributes.title + "</a></td>" +
                                        "<td>" + myDeserializedObjList[item].attributes.recordedOn + "</td>"+
                                        "<td id='t" + item + "'>" + owner + "</td></tr>");

I tried asp:Hyperlink. But doesn't work. Can anyone please help me.

If you are creating this control list that is table from your server code, then better use the Table Control and add each row and column based on your database table

In the specified table cell you have to create HtmlAnchor or HyperLink control as you wish and add it to table cell control collection.

then add this table control created in server code to any div that is set runat = server in html source

EDIT

You may refer this link to see how dynamically add table row and cell to a table control.

event handler to the dynamic anchor control can added using anch.OnClick += eventhandler;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM