Pregunta

<asp:LinkButton ID="lnkBtn" runat="server" CssClass="csstab" Text='<%#Eval("Name")%>'
OnClientClick="return ShowInEditMode('<%#Eval("ID") %>')"></asp:LinkButton>

I want to call the OnClientClick to call javascript method with passing a parameter. I am getting Server Tag is not well formed error. I tried changing double quotes to single quote etc, still the same issue.

The server tag is not well formed. LinkButton inside repeater

¿Fue útil?

Solución

Your OnClientClick event is having some wrong things.

use OnClientClick in the following way

OnClientClick='<%# string.Format("javascript:return ShowInEditMode({0})", Eval("ID"))%>'

Otros consejos

Well use this in html bit

<asp:LinkButton ID="lnkBtn" runat="server" CssClass="csstab" Text='<%#Eval("Name")%>' OnClientClick='<%#CreateShowInEditModeMethod(Eval("ID")) %>'></asp:LinkButton>

Then define this in your code behind

 protected string CreateShowInEditModeMethod(string str)
 {
        return String.Format("return ShowInEditMode('{0}');", str);
 }

let me know if did not solved :)

Replace external double quotes with single and & Eval quotes to double will work.

change onClientClick to:

OnClientClick='return ShowInEditMode("<%#Eval("ID") %>")'
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top