Web and Software Development

Google
 

Saturday, October 31, 2009

Adding Server Control Dynamically in ASP.Net

New or Casual Coder feels difficult to create asp.net server controls dynamically. I am givin an example to add Panel Control(which servers as a containter for other server controls ) and a Label control into asp.net form dynamically. The following in the code portion which is to be written in the Page_Load.



protected void Page_Load(object sender, EventArgs e)
{
Panel p1 = new Panel();
this.form1.Controls.Add(p1);
Label l1= new Label();
l1.Text="Test Label in Panel";

p1.Width = 200;
p1.Height = 200;
p1.BackColor = System.Drawing.Color.Red;
p1.BorderColor = System.Drawing.Color.Black;
p1.Controls.Add(l1);
p1.Visible = true;
p1.Enabled = true;
}


Explanation:
First line on code creates an instance of Panel by the name p1, second line adds this panel instance "p1" to the current asp.net form "form1", next line creates an instance of lable control in the name of "l1" and assign some text to it. Next line changes some properties like height, width and backgournd color etc. After that Newly created label "l1" is added to a panel "p1";

Tuesday, December 4, 2007

Evaluation of Mathematical Formulae using C- Langauge

1. Fiding area of tirangle using Hero's Formula (C-language). Hero's Formula is
Area=squarerootof(S(S-a)(S-b)(S-c) where a,b,c are the sides of triangle and S=(a+b+c)/2 is the semiperimeter of trinagle.

void main()
{
float a,b,c,ans;
float area(float,float,float); //Prototype or Function Declaration
clrscr();

printf("\n Enter the First Side of Triangle");
scanf("%f",&a);
printf("\n Enter the Second Side of Triangle");
scanf("%f",&b);
printf("\n Enter the Third Side of Triangle");
scanf("%f",&c);

ans=area(a,b,c);//Calling function for a,b,c;

printf("\n Area of Give Triangle is =%.2f,ans);
getch();
}

//Function Definition

float area(float p, float q, float r)
{

float s, mult, sq;
s=(a+b+c)/2;
mult=s*(s-a)*(s-b)*(s-c);
sq=sqrt(mult); //sqrt() is defined in math.h and used to find square root of given number
return(sq);
}


Tuesday, November 20, 2007

Graphics Demo in C- Langauge

Using Various Graphics Functions in C -Language


void main()
{
int gd=0,gm=0;
initgraph(&gd,&gm,"..\\bgi");
setcolor(GREEN);
outtextxy((getmaxx()/2)-70,20,"GRAPHICSDEMO");
setcolor(RED);
circle(100,150,50);
outtextxy(75,145,"Circle");
line(175,150,250,150);
outtextxy(180,160,"Line");
fillellipse(400,150,100,50);
setcolor(RED);
outtextxy(375,145,"FillEllipse");
arc(100,350,30,90,100);
outtextxy(120,300,"Arc");
putpixel(275,270,GREEN);
outtextxy(255,300,"PIXEL");
getch();
closegraph();
}

Note: include graphics.h header file

Boomark My Blog @