Markup syntax for inserting button's client id into onclick event?

Discussion in 'ASP .Net' started by Bogdan, May 21, 2009.

  1. Bogdan

    Bogdan Guest

    Hi,

    A button in aspx is as follows:

    <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete"
    Text="Finish"
    OnClientClick="scheduleDisable('???');" />

    Is there a way to declaratively replace ??? with the button's client ID?
    I'm looking for something like '<% FinishButton.ClientID %>' which obviously
    is wrong.

    I could easily do it programmatically but I need to use markup in this case.

    Thanks,
    Bogdan
    Bogdan, May 21, 2009
    #1
    1. Advertising

  2. Bogdan

    Bogdan Guest

    Mark,

    Thanks for the quick reply. Unfortunately your suggestion did not work for
    me.
    It renders as: onclick="scheduleDisable('&lt;%=FinishButton.ClientID%>');

    Any thoughts?
    Thanks,
    Bogdan

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Bogdan" <> wrote in message
    > news:%...
    >
    >> <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete"
    >> Text="Finish"
    >> OnClientClick="scheduleDisable('???');" />
    >>
    >> Is there a way to declaratively replace ??? with the button's client ID?
    >> I'm looking for something like '<% FinishButton.ClientID %>' which
    >> obviously is wrong.

    >
    > OnClientClick="scheduleDisable('<%=FinishButton.ClientID%>');
    >
    > In this instance, the = sign is ASP.NET shorthand for Response.Write
    >
    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    Bogdan, May 21, 2009
    #2
    1. Advertising

  3. The id doesn't have to come from server side:

    OnClientClick="scheduleDisable(this.id);"


    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Bogdan" <> wrote in message
    news:%...
    > Hi,
    >
    > A button in aspx is as follows:
    >
    > <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete"
    > Text="Finish"
    > OnClientClick="scheduleDisable('???');" />
    >
    > Is there a way to declaratively replace ??? with the button's client ID?
    > I'm looking for something like '<% FinishButton.ClientID %>' which
    > obviously is wrong.
    >
    > I could easily do it programmatically but I need to use markup in this
    > case.
    >
    > Thanks,
    > Bogdan
    >
    >
    >
    >
    > __________ Information from ESET NOD32 Antivirus, version of virus
    > signature database 4094 (20090521) __________
    >
    > The message was checked by ESET NOD32 Antivirus.
    >
    > http://www.eset.com
    >
    >
    >



    __________ Information from ESET NOD32 Antivirus, version of virus signature database 4094 (20090521) __________

    The message was checked by ESET NOD32 Antivirus.

    http://www.eset.com
    Eliyahu Goldin, May 21, 2009
    #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. Purvi T
    Replies:
    0
    Views:
    802
    Purvi T
    Oct 19, 2004
  2. sklett
    Replies:
    3
    Views:
    423
    sklett
    Jan 29, 2004
  3. altergothen
    Replies:
    2
    Views:
    369
    Hans Kesting
    Apr 19, 2004
  4. AAaron123
    Replies:
    7
    Views:
    3,682
    AAaron123
    Aug 21, 2009
  5. Replies:
    2
    Views:
    233
Loading...

Share This Page