Reputation: 137
I'm trying to call a javascript function when repeater binding from the code behind.
Here is the sample code that i'm tring to call javascript function:
<asp:Repeater ID="summeryR" runat="server">
<ItemTemplate>
<div class="question-head">
<p><%# Eval("QuestionText") %></p>
</div>
<div class="question-respond">
<p><%# Eval("Label", "checkSkipQuestion()") %></p>
</div>
</ItemTemplate>
</asp:Repeater>
here is the javascript function:
function checkSkipQuestion()
{
alert("checkSkipQuestion");
}
Upvotes: 0
Views: 1673
Reputation: 1
<p><%# Eval("Label", "<script type=text/java-script> alert('Hi..') ;
</script>") %></p>
if it is not work then remove dash from type.
Upvotes: 0
Reputation: 7356
This can not be done.
The IIS server is processing the repeater and building an HTML table. This happens during compile time of the page. Once the page is compiled, and completed as HTML by the server, it is sent to the browser. At that point, any JavaScript can be run. In other words, you cannot call a JavaScript function while the repeater is building the table.
Upvotes: 1