DataBinding expressions are not evaluated on Custom Properties of a UserControl

  • Thread starter Jason Wright via .NET 247
  • Start date

J

Jason Wright via .NET 247

Hiya,

I've created a UserControl with some Custom properties and assigned databinding expressions to the properties in the aspx. Does anyone know why these expressions are not being evaluated?

eg.
<uc1:ControlX id="la" runat="server" ClientClick='javascriptfunction(<%# DataBinder.Eval(Container.DataItem, "Id")%>)' />

after processing renders in html as

<table id="la" [other attributes] onclick="javascriptfunction(<%# DataBinder.Eval(Container.DataItem, &quot;Id&quot;) %>)">

instead of

<table id="la" [other attributes] onclick="javascriptfunction(1)">

ControlX is implemented as follows:

public class ControlX : UserControl
{
private HtmlTable tableControl;

[other stuff]

public string ClientClick
{
set
{
tableControl.Attributes["onclick"] = value;
}
}

[other stuff]
}
 
Ad

Advertisements

J

John Saunders

Jason Wright via .NET 247 said:
Hiya,

I've created a UserControl with some Custom properties and assigned
databinding expressions to the properties in the aspx. Does anyone know why
these expressions are not being evaluated?
eg.
<uc1:ControlX id="la" runat="server" ClientClick='javascriptfunction(<%#
DataBinder.Eval(Container.DataItem, "Id")%>)' />

What happens when you do the exact same thing to a label control?
 
Ad

Advertisements

B

Brian W

I'm seeing this same problem on any thing that has a runat=server attribute
have you found a solution to this problem?

This:
<a runat="server" href='./check.aspx?x=<%# MyValue%>'>Check This</a>

produces:
<a href="./check.aspx?x=<%# MyValue%>">Check This</a>

and this:
<asp:hyperlink runat="server" NavigateUrl='./check.aspx?x=<%#
MyValue%>'>Check This Too</asp:hyperlink>

also produces
<a href="./check.aspx?x=<%# MyValue%>">Check This</a>

however this:
<a href="./check.aspx?x=<%# MyValue%>">Check This</a>

produces:
<a href="./check.aspx?x=whatevervalue">Check This</a>


TIA
Brian W



Jason Wright via .NET 247 said:
Hiya,

I've created a UserControl with some Custom properties and assigned
databinding expressions to the properties in the aspx. Does anyone know why
these expressions are not being evaluated?
eg.
<uc1:ControlX id="la" runat="server" ClientClick='javascriptfunction(<%#
DataBinder.Eval(Container.DataItem, "Id")%>)' />
after processing renders in html as

<table id="la" [other attributes] onclick="javascriptfunction(<%#
DataBinder.Eval(Container.DataItem, &quot;Id&quot;) %>)">
instead of

<table id="la" [other attributes] onclick="javascriptfunction(1)">

ControlX is implemented as follows:

public class ControlX : UserControl
{
private HtmlTable tableControl;

[other stuff]

public string ClientClick
{
set
{
tableControl.Attributes["onclick"] = value;
}
}

[other stuff]
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top