문제

<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

도움이 되었습니까?

해결책

Your OnClientClick event is having some wrong things.

use OnClientClick in the following way

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

다른 팁

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") %>")'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top