How to Create a web control library
Hi Frnd's..
I'm New to C#.net.Can anyone say how to Create a web control library
in C#.net Step by Step Process...
Tks In Adv...
G.Sam...
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
LisaRank #8,652 · 218 reputationPosted Feb 17, 2009, 1:54 AM EST
did you meant a class library??
if it is then just go to new project and select the option Class Library under the windows in your selected environment and you can start designing the library as and how you need.
Thanks,
Lisa
sam caleb38 reputationPosted Feb 17, 2009, 2:01 AM EST
")); t1.ID = "t1sam"; t1.ForeColor = System.Drawing.Color.Azure; Controls.Add(t1); RequiredFieldValidator rf = new RequiredFieldValidator(); rf.ID = "rfsam"; rf.ErrorMessage = "Values Needed"; rf.ControlToValidate ="t1sam"; Controls.Add(rf); Controls.Add(new LiteralControl("
")); b1.ID = "b1sam"; b1.ForeColor = System.Drawing.Color.Blue; //buttonCell.Width = Unit.Pixel(1); b1.Width = Unit.Pixel(1); Controls.Add(b1); Controls.Add(new LiteralControl("
")); EnsureChildControls(); } protected override void OnInit(EventArgs e) { l1.Text = "Enter Data"; b1.Text = "Submit"; base.OnInit(e); } private void b1sam_Click(object sender, EventArgs e) { } } } Tks in Adv... G.sam...
LisaRank #8,652 · 218 reputationPosted Feb 17, 2009, 2:28 AM EST
sorry, but i cant read any of your code its all messed up and do tell me what error are you getting stuck at ?
but taking a closer look at it , it looks like you set all of your functions to protected level, which i doubt will not allow you to access unless it is a derived class so try changing it to public methods
it should work.
Thanks,
Lisa
sam caleb38 reputationPosted Feb 17, 2009, 3:43 AM EST
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
namespace samLibray
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:WebCustomControl1 runat=server>{0}:WebCustomControl1>")]
public class WebCustomControl1 : WebControl
{
public TextBox t1 = new TextBox();
public Button b1 = new Button();
public Label l1 = new Label();
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState["Text"] = value;
}
}
protected override void RenderContents(HtmlTextWriter output)
{
output.Write(Text);
}
protected override void CreateChildControls()
{
l1.ID = "l1sam";
l1.BorderColor = System.Drawing.Color.Chocolate;
Controls.Add(l1);
Controls.Add(new LiteralControl("
"));
t1.ID = "t1sam";
t1.ForeColor = System.Drawing.Color.Azure;
Controls.Add(t1);
RequiredFieldValidator rf = new RequiredFieldValidator();
rf.ID = "rfsam";
rf.ErrorMessage = "Values Needed";
rf.ControlToValidate ="t1sam";
Controls.Add(rf);
Controls.Add(new LiteralControl("
"));
b1.ID = "b1sam";
b1.ForeColor = System.Drawing.Color.Blue;
//buttonCell.Width = Unit.Pixel(1);
b1.Width = Unit.Pixel(1);
Controls.Add(b1);
Controls.Add(new LiteralControl("
"));
EnsureChildControls();
}
protected override void OnInit(EventArgs e)
{
l1.Text = "Enter Data";
b1.Text = "Submit";
base.OnInit(e);
}
private void b1sam_Click(object sender, EventArgs e)
{
}
}
}
Tks in Adv...
G.Sam...
LisaRank #8,652 · 218 reputationPosted Feb 17, 2009, 3:52 AM EST
all the protected and private methods and variables will be invisible, you can only access public methods by referencing to the dll unless the class is a derived class of the parent class.
I hope it helps.
Thanks,
Lisa
LisaRank #8,652 · 218 reputationPosted Feb 17, 2009, 3:58 AM EST
say for example you created a namespace called samLibray u then need to add the dll to refrence in your project you want to call and add the namespace
using samLibray in the class you want to use.
then you can create an object instance of the class like
samLibray sl1 = new samLibray();
and use the methods and variables using sl.onInit() etc..
Thanks,
Lisa