DataBinding expressions are not evaluated on Custom Properties of a UserControl

Discussion in 'ASP .Net' started by Jason Wright via .NET 247, Jun 5, 2004.

  1. 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>
     
    Jason Wright via .NET 247, Jun 5, 2004
    #1
    1. Advertising

  2. "Jason Wright via .NET 247" <> wrote in message
    news:...
    > 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
     
    John Saunders, Jun 5, 2004
    #2
    1. Advertising

  3. Jason Wright via .NET 247

    Brian W Guest

    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" <> wrote in message
    news:...
    > 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>
     
    Brian W, Jun 12, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=

    Databinding to custom properties of a custom class in ASP.NET 2

    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=, Apr 20, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    608
    =?Utf-8?B?SW1hciBTcGFhbmphYXJz?=
    Apr 20, 2005
  2. Replies:
    0
    Views:
    461
  3. Chris
    Replies:
    1
    Views:
    3,983
    Christophe Vanfleteren
    Jan 9, 2004
  4. jobs
    Replies:
    0
    Views:
    1,773
  5. Earl Teigrob
    Replies:
    1
    Views:
    445
    Shravan
    Mar 1, 2004
Loading...

Share This Page