javascript - how do you access 'this' control's clientID or just do Bootstrap's .popover() in jscript -
the 'this' i'm talking first argument of creatediv function call below. it's linkbutton clicked.
<asp:linkbutton id="btn_reportreply1" runat="server" class="btn btn-danger btn-xs" text="reportreply" onclientclick='<%# string.format("creatediv(this," + eval("uniqueno") +","+ eval("commentseqno") + "," + eval("userno") + ", \"{0}\");", eval("loginid")) %>' ></asp:linkbutton>
now want 'this' button want call bootstrap .popover() it. below i'm trying btn's clientid , .popover() red underline shows under btn.clientid. , cannot use button's class because there several buttons have same class.
function creatediv(btn, replyno, commentseqno,reporteduserno, loginid) { $('#' + '<%= btn.clientid %>').popover({ trigger: 'manual', placement: 'left', content: vtype + vcontent }); $('#' + '<%= btn.clientid %>').popover("show");
}
onclientclick
rendered onclick
on dom object. this
in scope dom object itself, can use btn.id
clientid
or use $(btn)
in function.
here's sample:
markup
<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="webapplication1._default" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script type="text/javascript" src="scripts/jquery-1.7.1.js"></script> <script type="text/javascript"> function creatediv(btn) { $(btn).text($(btn).attr('id')); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:repeater runat="server" id="list"> <itemtemplate> <div> <asp:linkbutton id="thisismyid" text="<%# container.dataitem %>" runat="server" onclientclick="creatediv(this); return false;" /> </div> </itemtemplate> </asp:repeater> </div> </form> </body> </html>
code behind
using system; namespace webapplication1 { public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { list.datasource = new string[] { "test1", "test2" }; this.databind(); } } }
Comments
Post a Comment