unable to drag the cutom server control (button) on webform

P

prasadrmarathe

Hi,

I have created one custom buton server control which will shown on it
the nuber of time
it was clicked as its text.

I have added the custom control in my another projects tool box but i
am unable to drag the custom control on my webform.
can u please tell what the problem is .
i have provided the code below

thanks.
Prasad.





using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace CustomControls
{
/// <summary>
/// Summary description for WebCustomControl1.
/// </summary>

public class CountedButton : System.Web.UI.WebControls.Button
{
//private string text;

public CountedButton( )
{
this.Text = "Click me";
ViewState["Count"] = 0;
}

public int Count
{
get
{
return (int) ViewState["Count"];
}

set
{
ViewState["Count"]=value;
}
}

protected override void OnClick(EventArgs e)
{
ViewState["Count"]=((int)ViewState["Count"]) +1;
this.Text=ViewState["Count"]+ " Clicks";
base.OnClick(e);
}

/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>

}
}
 
G

Guest

Put the required ToolboxData attribute just above your class definition:

[ToolboxData("<{0}:CountedButton runat=server></{0}:CountedButton>")]

Peter
 

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

Top