Question

<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

Was it helpful?

Solution

Your OnClientClick event is having some wrong things.

use OnClientClick in the following way

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

OTHER TIPS

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") %>")'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top