Attach javascript to toolbar button

Discussion in 'ASP .Net' started by Ashish, Feb 22, 2004.

  1. Ashish

    Ashish Guest

    Hello,
    I am sick and tired of ochestrating server and client side scripts.
    Basically I am using toolbar from IE web controls and want to attach
    javascript to one of the buttons' click event. The problem is that button
    doesnt exposes attribute collection. I can attach javascript to whole
    toolbar but 1. it would defeat the purpose of only attaching client scripts
    to some buttons 2. i would have no means of identifying which button was
    clicked....

    Please help !!! Thanks !!!
    Ashish
    Ashish, Feb 22, 2004
    #1
    1. Advertising

  2. Hi Ashish,
    For eg :
    In the ButtonClick event of your Toolbar,
    If you have 2 buttons with button text Save and print ,
    if (sender.GetType().ToString() ==
    "Microsoft.Web.UI.WebControls.ToolbarButton")
    {



    Microsoft.Web.UI.WebControls.ToolbarLabel LblButton =
    (Microsoft.Web.UI.WebControls.ToolbarLabel)sender;

    if(LblButton.Text.IndexOf(" Save") > -1)

    {



    LiteralControl li1=new LiteralControl();

    li1.Text="<script>alert('Button Save is clicked.');</script>";

    Page.Controls.Add(li1);

    }

    else if(LblButton.Text.IndexOf("Print") > -1)

    {



    LiteralControl li2=new LiteralControl();

    li2.Text="<script>alert('Button Print is clicked.');</script>";

    Page.Controls.Add(li2);

    }

    }

    Hope this helps.

    Regards,

    Marshal Antony

    ..NET Developer

    http://www.dotnetmarshal.com





    "Ashish" <> wrote in message
    news:e$CZRqQ%...
    > Hello,
    > I am sick and tired of ochestrating server and client side scripts.
    > Basically I am using toolbar from IE web controls and want to attach
    > javascript to one of the buttons' click event. The problem is that button
    > doesnt exposes attribute collection. I can attach javascript to whole
    > toolbar but 1. it would defeat the purpose of only attaching client

    scripts
    > to some buttons 2. i would have no means of identifying which button was
    > clicked....
    >
    > Please help !!! Thanks !!!
    > Ashish
    >
    >
    Marshal Antony, Feb 22, 2004
    #2
    1. Advertising

  3. Ashish

    Ashish Guest

    Hi Antony,
    Thanks a lot ... worked like a charm...
    Ashish

    "Marshal Antony" <> wrote in message
    news:O2D2FjV%...
    > Hi Ashish,
    > For eg :
    > In the ButtonClick event of your Toolbar,
    > If you have 2 buttons with button text Save and print ,
    > if (sender.GetType().ToString() ==
    > "Microsoft.Web.UI.WebControls.ToolbarButton")
    > {
    >
    >
    >
    > Microsoft.Web.UI.WebControls.ToolbarLabel LblButton =
    > (Microsoft.Web.UI.WebControls.ToolbarLabel)sender;
    >
    > if(LblButton.Text.IndexOf(" Save") > -1)
    >
    > {
    >
    >
    >
    > LiteralControl li1=new LiteralControl();
    >
    > li1.Text="<script>alert('Button Save is clicked.');</script>";
    >
    > Page.Controls.Add(li1);
    >
    > }
    >
    > else if(LblButton.Text.IndexOf("Print") > -1)
    >
    > {
    >
    >
    >
    > LiteralControl li2=new LiteralControl();
    >
    > li2.Text="<script>alert('Button Print is clicked.');</script>";
    >
    > Page.Controls.Add(li2);
    >
    > }
    >
    > }
    >
    > Hope this helps.
    >
    > Regards,
    >
    > Marshal Antony
    >
    > .NET Developer
    >
    > http://www.dotnetmarshal.com
    >
    >
    >
    >
    >
    > "Ashish" <> wrote in message
    > news:e$CZRqQ%...
    > > Hello,
    > > I am sick and tired of ochestrating server and client side scripts.
    > > Basically I am using toolbar from IE web controls and want to attach
    > > javascript to one of the buttons' click event. The problem is that

    button
    > > doesnt exposes attribute collection. I can attach javascript to whole
    > > toolbar but 1. it would defeat the purpose of only attaching client

    > scripts
    > > to some buttons 2. i would have no means of identifying which button was
    > > clicked....
    > >
    > > Please help !!! Thanks !!!
    > > Ashish
    > >
    > >

    >
    >
    Ashish, Feb 22, 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. Replies:
    0
    Views:
    630
  2. Warren Tang
    Replies:
    1
    Views:
    527
    Warren Tang
    Sep 17, 2008
  3. Jim Mitchell
    Replies:
    0
    Views:
    180
    Jim Mitchell
    Jul 12, 2003
  4. Ashish

    how to attach javascript to toolbar button control

    Ashish, Feb 22, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    156
    Marshal Antony
    Feb 22, 2004
  5. pcouas
    Replies:
    0
    Views:
    232
    pcouas
    Feb 19, 2007
Loading...

Share This Page