By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,857 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

DataBinding expressions are not evaluated on Custom Properties of a UserControl

P: n/a
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]
}

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>EQjGw+v9EkOrDqH+z7828A==</Id>
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Jason Wright via .NET 247" <an*******@dotnet247.com> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
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?
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

P: n/a
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" <an*******@dotnet247.com> wrote in message
news:u6**************@TK2MSFTNGP09.phx.gbl...
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]
}

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>EQjGw+v9EkOrDqH+z7828A==</Id>

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.