Showing posts with label eval. Show all posts
Showing posts with label eval. 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;
}

Thursday, March 22, 2012

Server.HtmlEncode DataBinder

Can anyone help with Server.HtmlEncode encoding this?

'<%# DataBinder.Eval(Container.DataItem, "CAT_ID",
"pageview.aspx?tab=1&catid={0}") %
I've tried using similar to this:
<%# Server.HtmlEncode(DataBinder.Eval(Container,
"DataItem.Field1").ToString()) %
but get error message BC30455: Argument not specified for parameter '

Many thanks'<%#"/admin/managenews.aspx?action=2&id="+DataBinder.Eval(Container.DataItem,"NID")%>'
this may help u
"Fossie" <gillmcd@.ihug.co.nz> wrote in message
news:1148111001.439320.296410@.38g2000cwa.googlegro ups.com...
> Can anyone help with Server.HtmlEncode encoding this?
> '<%# DataBinder.Eval(Container.DataItem, "CAT_ID",
> "pageview.aspx?tab=1&catid={0}") %>
> I've tried using similar to this:
> <%# Server.HtmlEncode(DataBinder.Eval(Container,
> "DataItem.Field1").ToString()) %>
> but get error message BC30455: Argument not specified for parameter '
> Many thanks
Thanks - I tried the + and got this error message:

Conversion from string "pageview.aspx?tab=1&catid=1" to type 'Double'
is not valid.
'<%#"/pageview.aspx?tab=1&catid="+DataBinder.Eval(Container.DataItem,"CAT_ID")%>'
"Fossie" <gillmcd@.ihug.co.nz> wrote in message
news:1148112901.230750.47520@.j73g2000cwa.googlegro ups.com...
> Thanks - I tried the + and got this error message:
> Conversion from string "pageview.aspx?tab=1&catid=1" to type 'Double'
> is not valid.
<asp:HyperLink id="hyperlinkk1" Runat="server"
NavigateUrl='<%#"/pageview.aspx?tab=1&catid="+DataBinder.Eval(Container.DataItem,"CAT_ID")%>'</asp:HyperLink>
"Fossie" <gillmcd@.ihug.co.nz> wrote in message
news:1148112901.230750.47520@.j73g2000cwa.googlegro ups.com...
> Thanks - I tried the + and got this error message:
> Conversion from string "pageview.aspx?tab=1&catid=1" to type 'Double'
> is not valid.

Server.HtmlEncode DataBinder

Can anyone help with Server.HtmlEncode encoding this?
'<%# DataBinder.Eval(Container.DataItem, "CAT_ID",
"pageview.aspx?tab=1&catid={0}") %>
I've tried using similar to this:
<%# Server.HtmlEncode(DataBinder.Eval(Container,
"DataItem.Field1").ToString()) %>
but get error message BC30455: Argument not specified for parameter '
Many thanks'<%#"/admin/managenews.aspx?action=2&id="+DataBinder.Eval(Container.DataItem
,"NID")%>'
this may help u
"Fossie" <gillmcd@.ihug.co.nz> wrote in message
news:1148111001.439320.296410@.38g2000cwa.googlegroups.com...
> Can anyone help with Server.HtmlEncode encoding this?
> '<%# DataBinder.Eval(Container.DataItem, "CAT_ID",
> "pageview.aspx?tab=1&catid={0}") %>
> I've tried using similar to this:
> <%# Server.HtmlEncode(DataBinder.Eval(Container,
> "DataItem.Field1").ToString()) %>
> but get error message BC30455: Argument not specified for parameter '
> Many thanks
>