Showing posts with label description. Show all posts
Showing posts with label description. Show all posts

Monday, March 26, 2012

Server tag not well formed

This thing always gets me.

onclick="DisplayExamMessage('<%# Eval("Description") %>')"

Any ideas!

What is the onclick coming from? A Button or a picture?


Its a asp.net hyperlink control.

<asp:HyperLink id="hlDescription" onclick="DisplayExamMessage()" NavigateUrl="#" Text="Read Description" runat="server"> </asp:HyperLink

Try

onclick=<%# DisplayExamMessage(Eval("Description").ToString()) %>


Hi,

But DisplayExamMessage is a JavaScript function.

onclick=<%# DisplayExamMessage(Eval("Description").ToString()) %>

Function DisplayExamMessage(ByVal t As String)

Return "DisplayExamMessage('" & t & "');"
End Function

Ugly but should work


I see.

Add DisplayExamMessage() to your server script. Then, do this:

protected string DisplayExamMessage(string descrition)
{
if(descrition.Trim().Length != 0)
return "javascript:DisplayExamMessage(" + descrition + ");"; //I use same name for your

//server script and javascript. You can use different name

else
return string.Empty;
}