Attach javascript to toolbar button

A

Ashish

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
 
M

Marshal Antony

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top