Databinding in tag problem!

Discussion in 'ASP .Net' started by Henk, Aug 14, 2006.

  1. Henk

    Henk Guest

    Hello,
    I have a problem, with a gridview, i won't a javascript function,
    OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add an
    onclick event to the img tag like this. (this is in the itemtemplate off the
    gridview)

    <img src="img/edit.gif" style="width: 18px; height: 18px"
    onclick="OpenPopUp('EDIT','true',<%#Container.DataItem("RegistrationID")%>)"
    />

    this works fine, but why isnt the folowing code working:

    <asp:ImageButton ID="btnEdit" runat="server"
    OnClientClick="OpenPopUp('Edit',
    'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
    />

    I get some kind of error, server tag not well formed??
    Can someone help me??

    Thanks in regard..
    Henk, Aug 14, 2006
    #1
    1. Advertising

  2. Henk

    Patrick Jox Guest

    I think this is a problem with the quotation marks. I would try something
    like this.

    OnClientClick='OpenPopUp("Edit",
    "true",<%#Container.DataItem("RegistrationID")%>)'

    Not sure but hope this helps
    Patrick

    "Henk" <> schrieb im Newsbeitrag
    news:44e0b307$0$9404$2.nl...
    > Hello,
    > I have a problem, with a gridview, i won't a javascript function,
    > OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add
    > an onclick event to the img tag like this. (this is in the itemtemplate
    > off the gridview)
    >
    > <img src="img/edit.gif" style="width: 18px; height: 18px"
    > onclick="OpenPopUp('EDIT','true',<%#Container.DataItem("RegistrationID")%>)"
    > />
    >
    > this works fine, but why isnt the folowing code working:
    >
    > <asp:ImageButton ID="btnEdit" runat="server"
    > OnClientClick="OpenPopUp('Edit',
    > 'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
    > />
    >
    > I get some kind of error, server tag not well formed??
    > Can someone help me??
    >
    > Thanks in regard..
    >
    >
    >
    Patrick Jox, Aug 14, 2006
    #2
    1. Advertising

  3. you have two problems. binding expressing must be the only specification of
    an attribute value:

    <asp:ImageButton ID="btnEdit" runat="server"
    OnClientClick='<%# "OpenPopUp('Edit', 'true'," +
    Container.DataItem("RegistrationID") + ")" %>'
    ImageUrl="img/edit.gif"
    />

    also the ImageButton will perform a browser postback, so you must cancel the
    postback unless you want it.

    -- bruce (sqlwork.com)


    "Henk" <> wrote in message
    news:44e0b307$0$9404$2.nl...
    > Hello,
    > I have a problem, with a gridview, i won't a javascript function,
    > OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add
    > an onclick event to the img tag like this. (this is in the itemtemplate
    > off the gridview)
    >
    > <img src="img/edit.gif" style="width: 18px; height: 18px"
    > onclick="OpenPopUp('EDIT','true',<%#Container.DataItem("RegistrationID")%>)"
    > />
    >
    > this works fine, but why isnt the folowing code working:
    >
    > <asp:ImageButton ID="btnEdit" runat="server"
    > OnClientClick="OpenPopUp('Edit',
    > 'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
    > />
    >
    > I get some kind of error, server tag not well formed??
    > Can someone help me??
    >
    > Thanks in regard..
    >
    >
    >
    bruce barker \(sqlwork.com\), Aug 14, 2006
    #3
  4. Henk

    vMike Guest

    "Henk" <> wrote in message
    news:44e0b307$0$9404$2.nl...
    > Hello,
    > I have a problem, with a gridview, i won't a javascript function,
    > OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add

    an
    > onclick event to the img tag like this. (this is in the itemtemplate off

    the
    > gridview)
    >
    > <img src="img/edit.gif" style="width: 18px; height: 18px"
    >

    onclick="OpenPopUp('EDIT','true',<%#Container.DataItem("RegistrationID")%>)"
    > />
    >
    > this works fine, but why isnt the folowing code working:
    >
    > <asp:ImageButton ID="btnEdit" runat="server"
    > OnClientClick="OpenPopUp('Edit',
    > 'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
    > />
    >
    > I get some kind of error, server tag not well formed??
    > Can someone help me??
    >
    > Thanks in regard..
    >
    >

    Try something like this.

    OnClientClick=<%# "OpenPopUp('Edit', 'true'," +
    Container.DataItem("RegistrationID") + ")" %>
    vMike, Aug 14, 2006
    #4
    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. jstack
    Replies:
    1
    Views:
    606
    Tor Iver Wilhelmsen
    Jul 4, 2003
  2. shruds
    Replies:
    1
    Views:
    791
    John C. Bollinger
    Jan 27, 2006
  3. jobs
    Replies:
    0
    Views:
    1,620
  4. Earl Teigrob
    Replies:
    1
    Views:
    402
    Shravan
    Mar 1, 2004
  5. Henk

    Databinding in tag problem!

    Henk, Aug 14, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    135
    vMike
    Aug 14, 2006
Loading...

Share This Page