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