locked
create customcontrol(its very urgent) RRS feed

  • Question

  • User-358266636 posted

    Hi:

            I just want to create webcustom control in which the  textbox  should display  currentdate and time.While drag and drop that custom control  on ASPX page the textbox which is placed on custom control should display current time.Can any one send  me code for the above task.

     

    Thanks in advance
     

    Monday, July 14, 2008 5:17 PM

Answers

  • User1174340047 posted

    hi,suresh_dotnet

    if i understand you correctly, you want to develop a custom text box server control which is used in many pages of your web site. when dragged on aspx page, the text box's show the current time. Right?

    you just have to extend the TextBox, compile the following code into a assembly and then add it to the tool box in the VS.

    public class ExTextBox : TextBox
    {
       public ExTextBox()
       {
          base.Text = DateTime.Now.ToString();
       }
    }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 15, 2008 4:42 AM

All replies

  • User1935660843 posted

    Why do you need a custom control, why not just put a text box on your page and set it like:

     

        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                TextBox1.Text = DateTime.Now.ToLongDateString();
            }
        }
     Maybe I'm not understanding what you're looking for...
    Monday, July 14, 2008 5:30 PM
  • User1174340047 posted

    hi,suresh_dotnet

    if i understand you correctly, you want to develop a custom text box server control which is used in many pages of your web site. when dragged on aspx page, the text box's show the current time. Right?

    you just have to extend the TextBox, compile the following code into a assembly and then add it to the tool box in the VS.

    public class ExTextBox : TextBox
    {
       public ExTextBox()
       {
          base.Text = DateTime.Now.ToString();
       }
    }
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 15, 2008 4:42 AM
  • User1935660843 posted

    My Crystal that would be a good way to do it...

    Give that man (or woman) some answer points [:)]

    Tuesday, July 15, 2008 12:00 PM