Nezir Zahirović

Simple using of AjaxControlToolkit in code behind C#

In  this  short post  I  will  show  you using   AjaxControlToolkit in code-behind.
I needed AjaxControlToolkit in my  web  site  because of effects  that  I want to use on it.
So,  first I  get AjaxControlToolkit from :  http://www.asp.net/(S(fu2l2uzphr2u3u45q2dnez55))/ajax/AjaxControlToolkit/Samples/  and  add reference to AjaxControlToolkit dll in my web site project.
In  picture above  you can see a PanelIT  for which I want  to make some rounded corners and drop shadows.
The  code : In   first  part we need to made panel corners rounded , so  I  use this.FindControl()  to find a  panel control with name "pIt" to whom we will make our changes. After that  we initialize a AjaxControlToolkit.RoundedCornersExtender and  set the needed values to his  properties and after that  we add those AjaxControlToolkit.RoundedCornersExtender to our TargetControlID = "pIt" panel control.
In the  next step we use  AjaxControlToolkit.DropShadowExtender initialization and setting a properties values and adding to TargetControlID = "pIt" .

   private void panelIt()
    {
        Panel p = (Panel)this.FindControl("pIt");//" + i.ToString());
        p.BackColor = Color.White;

       AjaxControlToolkit.RoundedCornersExtender r = new AjaxControlToolkit.RoundedCornersExtender();
        r.BorderColor = Color.Black;
        r.Corners = AjaxControlToolkit.BoxCorners.All;
        r.Radius = 5;
        r.TargetControlID = p.ID;
        this.Panel1.Controls.Add(r);

        AjaxControlToolkit.DropShadowExtender sh = new AjaxControlToolkit.DropShadowExtender();
        sh.TargetControlID = p.ID;
        sh.Rounded = true;
        sh.Width = 7;
        this.Panel1.Controls.Add(sh);

    }.

....our desired panel  looks  like this ....
SHARE
    Blogger Comment
    Facebook Comment

2 comments:

  1. Very informative post. Its really helpful for me and beginner too. Check out this link too its also having a nice post with wonderful explanation on
    Ajax Toolkit RoundedCornersExtender Control in ASP.Net...
    http://mindstick.com/Articles/afcfadfd-cd04-4d58-9b0e-0af3f95c2534/?Ajax%20Toolkit%20RoundedCornersExtender%20Control%20in%20ASP.Net

    Thanks

    ReplyDelete