質問

<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